annotate libpurple/protocols/jabber/auth.c @ 30762:e03f912141dd

Start moving p2p specific code to its own module.
author masca@cpw.pidgin.im
date Thu, 03 Jun 2010 21:07:08 +0000
parents 417a4e912738
children c79748e14499
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 {
28697
de8565bc63fe jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents: 28696
diff changeset
80 purple_connection_error_reason(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
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
126 /* Disable the account as the user has canceled 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) {
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
148 purple_connection_error_reason(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);
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
161 else if (mech_name)
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... */
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
189 purple_connection_error_reason(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) {
4f45aae3ace1 Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents: 28715
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: 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
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
234 purple_connection_error_reason(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);
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
250 purple_connection_error_reason(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");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
254 if(js->stream_id && 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
255 char *s, *hash;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
256
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
257 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
258 query = xmlnode_get_child(iq->node, "query");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
259 x = xmlnode_new_child(query, "username");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
260 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
261 x = xmlnode_new_child(query, "resource");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
262 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
263
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
264 x = xmlnode_new_child(query, "digest");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
265 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
266 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
267 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
268 g_free(hash);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
269 g_free(s);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
270 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
271 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
272
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
273 } else if(js->stream_id && (x = xmlnode_get_child(query, "crammd5"))) {
21854
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
274 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
275 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
276 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
277
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 /* 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
279 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
280 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
281 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
282 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
283 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
284 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
285 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
286
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
287 /* 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
288 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
289 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
290
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
291 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
292 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
293 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
294 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
295
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, "crammd5");
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
297
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
298 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
299
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
300 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
301 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
302
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
303 } 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
304 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
305 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
306 "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
307 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
308 purple_account_get_username(account));
21099
51cf02dbdb0e disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents: 21095
diff changeset
309 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
310 _("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
311 msg,
22143
70fc60344317 A few more of those "default_action" fixes
Mark Doliner <mark@kingant.net>
parents: 21949
diff changeset
312 1,
28697
de8565bc63fe jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents: 28696
diff changeset
313 account, NULL, NULL,
de8565bc63fe jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents: 28696
diff changeset
314 account, allow_plaintext_auth,
21099
51cf02dbdb0e disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents: 21095
diff changeset
315 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
316 g_free(msg);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
317 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
318 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
319 finish_plaintext_authentication(js);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
320 } else {
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
321 purple_connection_error_reason(js->gc,
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
322 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE,
20117
f24a2cacacd1 Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <will.thompson@collabora.co.uk>
parents: 19999
diff changeset
323 _("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
324 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
325 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
326 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
327 }
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 void jabber_auth_start_old(JabberStream *js)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
330 {
28697
de8565bc63fe jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents: 28696
diff changeset
331 PurpleAccount *account;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
332 JabberIq *iq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
333 xmlnode *query, *username;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
334
28697
de8565bc63fe jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents: 28696
diff changeset
335 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
336
28292
fa77b70c8ca6 jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents: 28096
diff changeset
337 /*
fa77b70c8ca6 jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents: 28096
diff changeset
338 * 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
339 * <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
340 * 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
341 */
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 if (!jabber_stream_is_ssl(js) &&
28697
de8565bc63fe jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents: 28696
diff changeset
343 purple_account_get_bool(account, "require_tls", JABBER_DEFAULT_REQUIRE_TLS)) {
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
344 purple_connection_error_reason(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
345 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
346 _("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
347 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
348 }
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
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
350 if (js->registration) {
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
351 jabber_register_start(js);
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
352 return;
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
353 }
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
354
28292
fa77b70c8ca6 jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents: 28096
diff changeset
355 /*
fa77b70c8ca6 jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents: 28096
diff changeset
356 * 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
357 * 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
358 * 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
359 */
fa77b70c8ca6 jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents: 28096
diff changeset
360 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
361 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
362 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
363 }
fa77b70c8ca6 jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents: 28096
diff changeset
364
16068
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
365 #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
366 /* 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
367 * 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
368 * password prompting here
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
369 */
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
370
28697
de8565bc63fe jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents: 28696
diff changeset
371 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
372 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
373 return;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
374 }
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
375 #endif
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
376 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
377
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
378 query = xmlnode_get_child(iq->node, "query");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
379 username = xmlnode_new_child(query, "username");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
380 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
381
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
382 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
383
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
384 jabber_iq_send(iq);
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
387 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
388 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
389 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
390 const char *ns = xmlnode_get_namespace(packet);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
391
28715
cea22db36ffc jabber: Use NS_XMPP_SASL
Paul Aurich <paul@darkrain42.org>
parents: 28707
diff changeset
392 if (!purple_strequal(ns, NS_XMPP_SASL)) {
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
393 purple_connection_error_reason(js->gc,
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
394 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
395 _("Invalid response from server"));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
396 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
397 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
398
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
399 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
400 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
401 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
402 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
403 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: 28715
diff changeset
404 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: 28715
diff changeset
405 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
406 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
407 } else if (response) {
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
408 jabber_send(js, response);
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
409 xmlnode_free(response);
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
410 }
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
411
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
412 g_free(msg);
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
413 } else
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
414 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
415 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
416
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
417 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
418 {
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
419 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
420
28715
cea22db36ffc jabber: Use NS_XMPP_SASL
Paul Aurich <paul@darkrain42.org>
parents: 28707
diff changeset
421 if (!purple_strequal(ns, NS_XMPP_SASL)) {
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
422 purple_connection_error_reason(js->gc,
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
423 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
424 _("Invalid response from server"));
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
425 return;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
426 }
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
427
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
428 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
429 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
430 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
431
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 (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: 28715
diff changeset
433 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: 28715
diff changeset
434 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
435 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
436 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
437 } 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: 28715
diff changeset
438 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: 28715
diff changeset
439 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
440 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
441 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
442 }
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
443
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
444 g_free(msg);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
445 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
446
28096
b357216b7b79 jabber: Fix using BOSH and legacy auth together. Closes #9990.
Paul Aurich <paul@darkrain42.org>
parents: 28048
diff changeset
447 /*
b357216b7b79 jabber: Fix using BOSH and legacy auth together. Closes #9990.
Paul Aurich <paul@darkrain42.org>
parents: 28048
diff changeset
448 * 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
449 * jabber_bosh_connection_send.
b357216b7b79 jabber: Fix using BOSH and legacy auth together. Closes #9990.
Paul Aurich <paul@darkrain42.org>
parents: 28048
diff changeset
450 */
b357216b7b79 jabber: Fix using BOSH and legacy auth together. Closes #9990.
Paul Aurich <paul@darkrain42.org>
parents: 28048
diff changeset
451 js->reinit = TRUE;
b357216b7b79 jabber: Fix using BOSH and legacy auth together. Closes #9990.
Paul Aurich <paul@darkrain42.org>
parents: 28048
diff changeset
452 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
453 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
454
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
455 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
456 {
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
457 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
458 char *msg = NULL;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
459
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
460 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
461 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
462 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
463
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
464 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
465 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
466 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
467 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
468 }
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
22767
d5b3afea8764 After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evan.s@dreskin.net>
parents: 22672
diff changeset
470 return;
d5b3afea8764 After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evan.s@dreskin.net>
parents: 22672
diff changeset
471 }
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
472 }
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
473
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
474 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
475 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
476
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
477 if (!msg) {
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
478 purple_connection_error_reason(js->gc,
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
479 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
480 _("Invalid response from server"));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
481 } else {
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
482 purple_connection_error_reason(js->gc, reason, msg);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
483 g_free(msg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
484 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
485 }
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
486
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
487 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
488 {
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
489 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
490 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
491
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
492 /* 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
493 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
494 return -1;
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
495 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
496 return 1;
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
497 /* 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
498 return 0;
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
499 }
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
500
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
501 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
502 {
28707
c1d41b7484ff jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents: 28699
diff changeset
503 JabberSaslMech **tmp;
c1d41b7484ff jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents: 28699
diff changeset
504 gint count, i;
c1d41b7484ff jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents: 28699
diff changeset
505
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
506 auth_mechs = g_slist_insert_sorted(auth_mechs, jabber_auth_get_plain_mech(), compare_mech);
28698
f27ed49948b7 jabber: Oops, re-enable DIGEST-MD5 (I was testing PLAIN).
Paul Aurich <paul@darkrain42.org>
parents: 28697
diff changeset
507 auth_mechs = g_slist_insert_sorted(auth_mechs, jabber_auth_get_digest_md5_mech(), compare_mech);
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
508 #ifdef HAVE_CYRUS_SASL
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
509 auth_mechs = g_slist_insert_sorted(auth_mechs, jabber_auth_get_cyrus_mech(), compare_mech);
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
510 #endif
28707
c1d41b7484ff jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents: 28699
diff changeset
511
c1d41b7484ff jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents: 28699
diff changeset
512 tmp = jabber_auth_get_scram_mechs(&count);
c1d41b7484ff jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents: 28699
diff changeset
513 for (i = 0; i < count; ++i)
c1d41b7484ff jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents: 28699
diff changeset
514 auth_mechs = g_slist_insert_sorted(auth_mechs, tmp[i], compare_mech);
28696
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
515 }
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
516
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
517 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
518 {
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
519 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
520 auth_mechs = NULL;
8ada06fb65ed jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents: 28520
diff changeset
521 }