libpurple/protocols/jabber/auth.c

Mon, 10 Feb 2014 16:22:00 +0530

author
Ankit Vani <a@nevitus.org>
date
Mon, 10 Feb 2014 16:22:00 +0530
branch
soc.2013.gobjectification.plugins
changeset 37108
73c5fb6d78b3
parent 35053
fbbbbf02ffbb
child 36049
bffbd724134d
permissions
-rw-r--r--

Merged default branch

7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1 /*
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2 * purple - Jabber Protocol Plugin
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
3 *
28322
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 27635
diff changeset
4 * Purple is the legal property of its developers, whose names are too numerous
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 27635
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 27635
diff changeset
6 * source distribution.
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
7 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
11 * (at your option) any later version.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
12 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
16 * GNU General Public License for more details.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
17 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
19859
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19852
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
21 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
22 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
23 #include "internal.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
24
15952
c087855dc551 Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15884
diff changeset
25 #include "account.h"
c087855dc551 Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15884
diff changeset
26 #include "debug.h"
20093
04f3c1dcd2cf applied changes from 5fda75104115d0a95c1e214b6b3ca18c4dc86a0c
Richard Laager <rlaager@pidgin.im>
parents: 19993
diff changeset
27 #include "core.h"
15952
c087855dc551 Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15884
diff changeset
28 #include "conversation.h"
c087855dc551 Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15884
diff changeset
29 #include "request.h"
c087855dc551 Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15884
diff changeset
30 #include "sslconn.h"
c087855dc551 Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15884
diff changeset
31 #include "util.h"
c087855dc551 Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15884
diff changeset
32 #include "xmlnode.h"
c087855dc551 Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 15884
diff changeset
33
26671
3970019332c8 Make the last one compile (add disco.h) and alphabetize.
Paul Aurich <darkrain42@pidgin.im>
parents: 26669
diff changeset
34 #include "auth.h"
3970019332c8 Make the last one compile (add disco.h) and alphabetize.
Paul Aurich <darkrain42@pidgin.im>
parents: 26669
diff changeset
35 #include "disco.h"
3970019332c8 Make the last one compile (add disco.h) and alphabetize.
Paul Aurich <darkrain42@pidgin.im>
parents: 26669
diff changeset
36 #include "jabber.h"
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
37 #include "jutil.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
38 #include "iq.h"
16180
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
39 #include "notify.h"
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
40
34567
ea5103f66b0e Refactor the codebase to use PurpleHash
Ankit Vani <a@nevitus.org>
parents: 34556
diff changeset
41 #include "ciphers/hmaccipher.h"
ea5103f66b0e Refactor the codebase to use PurpleHash
Ankit Vani <a@nevitus.org>
parents: 34556
diff changeset
42 #include "ciphers/md5hash.h"
34556
087db73b115d Refactored protocols bonjour, gg, jabber to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 34175
diff changeset
43
28855
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
44 static GSList *auth_mechs = NULL;
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
45
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
46 static void auth_old_result_cb(JabberStream *js, const char *from,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
47 JabberIqType type, const char *id,
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
48 PurpleXmlNode *packet, gpointer data);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
49
8397
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
50 static void finish_plaintext_authentication(JabberStream *js)
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
51 {
28855
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
52 JabberIq *iq;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
53 PurpleXmlNode *query, *x;
8397
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
54
28855
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
55 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:auth");
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
56 query = purple_xmlnode_get_child(iq->node, "query");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
57 x = purple_xmlnode_new_child(query, "username");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
58 purple_xmlnode_insert_data(x, js->user->node, -1);
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
59 x = purple_xmlnode_new_child(query, "resource");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
60 purple_xmlnode_insert_data(x, js->user->resource, -1);
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
61 x = purple_xmlnode_new_child(query, "password");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
62 purple_xmlnode_insert_data(x, purple_connection_get_password(js->gc), -1);
28855
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
63 jabber_iq_set_callback(iq, auth_old_result_cb, NULL);
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
64 jabber_iq_send(iq);
8397
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
65 }
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
66
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
67 static void allow_plaintext_auth(PurpleAccount *account)
8397
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
68 {
28856
992b7074357d jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <darkrain42@pidgin.im>
parents: 28855
diff changeset
69 PurpleConnection *gc;
992b7074357d jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <darkrain42@pidgin.im>
parents: 28855
diff changeset
70 JabberStream *js;
992b7074357d jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <darkrain42@pidgin.im>
parents: 28855
diff changeset
71
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
72 purple_account_set_bool(account, "auth_plain_in_clear", TRUE);
8397
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
73
28856
992b7074357d jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <darkrain42@pidgin.im>
parents: 28855
diff changeset
74 gc = purple_account_get_connection(account);
992b7074357d jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <darkrain42@pidgin.im>
parents: 28855
diff changeset
75 js = purple_connection_get_protocol_data(gc);
992b7074357d jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <darkrain42@pidgin.im>
parents: 28855
diff changeset
76
992b7074357d jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <darkrain42@pidgin.im>
parents: 28855
diff changeset
77 finish_plaintext_authentication(js);
8397
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
78 }
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
79
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
80 static void disallow_plaintext_auth(PurpleAccount *account)
8397
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
81 {
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 30898
diff changeset
82 purple_connection_error(purple_account_get_connection(account),
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21151
diff changeset
83 PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR,
20445
c900767c024b Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents: 19993
diff changeset
84 _("Server requires plaintext authentication over an unencrypted stream"));
8397
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
85 }
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
86
29008
1f288722b5cd jabber: Use NS_XMPP_SASL
Paul Aurich <darkrain42@pidgin.im>
parents: 28866
diff changeset
87 #ifdef HAVE_CYRUS_SASL
28855
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
88 static void
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
89 auth_old_pass_cb(PurpleConnection *gc, PurpleRequestFields *fields)
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
90 {
28855
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
91 PurpleAccount *account;
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
92 JabberStream *js;
16180
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
93 const char *entry;
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
94 gboolean remember;
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
95
28855
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
96 /* The password prompt dialog doesn't get disposed if the account disconnects */
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
97 if (!PURPLE_CONNECTION_IS_VALID(gc))
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
98 return;
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
99
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
100 account = purple_connection_get_account(gc);
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
101 js = purple_connection_get_protocol_data(gc);
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
102
16180
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
103 entry = purple_request_fields_get_string(fields, "password");
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
104 remember = purple_request_fields_get_bool(fields, "remember");
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
105
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
106 if (!entry || !*entry)
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
107 {
34513
6f6de16b4044 Fix build with Cyrus SASL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34331
diff changeset
108 purple_notify_error(account, NULL,
6f6de16b4044 Fix build with Cyrus SASL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34331
diff changeset
109 _("Password is required to sign on."), NULL,
6f6de16b4044 Fix build with Cyrus SASL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34331
diff changeset
110 purple_request_cpar_from_connection(gc));
28855
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
111 return;
16180
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
112 }
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
113
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
114 if (remember)
28855
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
115 purple_account_set_remember_password(account, TRUE);
16180
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
116
34029
059c1270db1f Remove the silly destroy argument from purple_account_set_password and
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34028
diff changeset
117 purple_account_set_password(account, entry, NULL, NULL);
20093
04f3c1dcd2cf applied changes from 5fda75104115d0a95c1e214b6b3ca18c4dc86a0c
Richard Laager <rlaager@pidgin.im>
parents: 19993
diff changeset
118
16180
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
119 /* Restart our connection */
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
120 jabber_auth_start_old(js);
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
121 }
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
122
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
123 static void
28856
992b7074357d jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <darkrain42@pidgin.im>
parents: 28855
diff changeset
124 auth_no_pass_cb(PurpleConnection *gc, PurpleRequestFields *fields)
16180
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
125 {
19852
4810415cdcfb 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 <datallah@pidgin.im>
parents: 19337
diff changeset
126 /* The password prompt dialog doesn't get disposed if the account disconnects */
28856
992b7074357d jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <darkrain42@pidgin.im>
parents: 28855
diff changeset
127 if (!PURPLE_CONNECTION_IS_VALID(gc))
19852
4810415cdcfb 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 <datallah@pidgin.im>
parents: 19337
diff changeset
128 return;
4810415cdcfb 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 <datallah@pidgin.im>
parents: 19337
diff changeset
129
30708
535bec1e66fb Standardize on "cancelled".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30356
diff changeset
130 /* Disable the account as the user has cancelled connecting */
28856
992b7074357d jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <darkrain42@pidgin.im>
parents: 28855
diff changeset
131 purple_account_set_enabled(purple_connection_get_account(gc), purple_core_get_ui(), FALSE);
16180
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
132 }
29008
1f288722b5cd jabber: Use NS_XMPP_SASL
Paul Aurich <darkrain42@pidgin.im>
parents: 28866
diff changeset
133 #endif
16180
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
134
8296
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8223
diff changeset
135 void
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
136 jabber_auth_start(JabberStream *js, PurpleXmlNode *packet)
8296
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8223
diff changeset
137 {
28855
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
138 GSList *mechanisms = NULL;
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
139 GSList *l;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
140 PurpleXmlNode *response = NULL;
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
141 PurpleXmlNode *mechs, *mechnode;
29084
3a821d391ac0 Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <darkrain42@pidgin.im>
parents: 29008
diff changeset
142 JabberSaslState state;
29090
b351fcdeede7 jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <darkrain42@pidgin.im>
parents: 29084
diff changeset
143 char *msg = NULL;
8296
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8223
diff changeset
144
8016
d75a4e86f7c3 [gaim-migrate @ 8696]
Nathan Walp <nwalp@pidgin.im>
parents: 7981
diff changeset
145 if(js->registration) {
d75a4e86f7c3 [gaim-migrate @ 8696]
Nathan Walp <nwalp@pidgin.im>
parents: 7981
diff changeset
146 jabber_register_start(js);
d75a4e86f7c3 [gaim-migrate @ 8696]
Nathan Walp <nwalp@pidgin.im>
parents: 7981
diff changeset
147 return;
d75a4e86f7c3 [gaim-migrate @ 8696]
Nathan Walp <nwalp@pidgin.im>
parents: 7981
diff changeset
148 }
d75a4e86f7c3 [gaim-migrate @ 8696]
Nathan Walp <nwalp@pidgin.im>
parents: 7981
diff changeset
149
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
150 mechs = purple_xmlnode_get_child(packet, "mechanisms");
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
151 if(!mechs) {
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 30898
diff changeset
152 purple_connection_error(js->gc,
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21151
diff changeset
153 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
27635
0cd19038c417 More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents: 27633
diff changeset
154 _("Invalid response from server"));
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
155 return;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
156 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
157
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
158 for(mechnode = purple_xmlnode_get_child(mechs, "mechanism"); mechnode;
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
159 mechnode = purple_xmlnode_get_next_twin(mechnode))
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
160 {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
161 char *mech_name = purple_xmlnode_get_data(mechnode);
23242
141db4dc5978 Skip the X-GOOGLE-TOKEN mech (given us by Google Talk when connecting with
Evan Schoenberg <evands@pidgin.im>
parents: 22967
diff changeset
162
28855
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
163 if (mech_name && *mech_name)
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
164 mechanisms = g_slist_prepend(mechanisms, mech_name);
30356
086e361eb7a9 Remove unnecessary check
Mark Doliner <markdoliner@pidgin.im>
parents: 30156
diff changeset
165 else
28855
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
166 g_free(mech_name);
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
167
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
168 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
169
28855
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
170 for (l = auth_mechs; l; l = l->next) {
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
171 JabberSaslMech *possible = l->data;
7703
118ef0876fe6 [gaim-migrate @ 8348]
Nathan Walp <nwalp@pidgin.im>
parents: 7645
diff changeset
172
28855
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
173 /* Is this the Cyrus SASL mechanism? */
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
174 if (g_str_equal(possible->name, "*")) {
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
175 js->auth_mech = possible;
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
176 break;
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
177 }
8397
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
178
28855
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
179 /* Can we find this mechanism in the server's list? */
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
180 if (g_slist_find_custom(mechanisms, possible->name, (GCompareFunc)strcmp)) {
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
181 js->auth_mech = possible;
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
182 break;
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
183 }
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
184 }
7703
118ef0876fe6 [gaim-migrate @ 8348]
Nathan Walp <nwalp@pidgin.im>
parents: 7645
diff changeset
185
30036
747b4a361046 jabber: --more leaks
Paul Aurich <darkrain42@pidgin.im>
parents: 29910
diff changeset
186 while (mechanisms) {
747b4a361046 jabber: --more leaks
Paul Aurich <darkrain42@pidgin.im>
parents: 29910
diff changeset
187 g_free(mechanisms->data);
747b4a361046 jabber: --more leaks
Paul Aurich <darkrain42@pidgin.im>
parents: 29910
diff changeset
188 mechanisms = g_slist_delete_link(mechanisms, mechanisms);
747b4a361046 jabber: --more leaks
Paul Aurich <darkrain42@pidgin.im>
parents: 29910
diff changeset
189 }
747b4a361046 jabber: --more leaks
Paul Aurich <darkrain42@pidgin.im>
parents: 29910
diff changeset
190
28855
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
191 if (js->auth_mech == NULL) {
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
192 /* Found no good mechanisms... */
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 30898
diff changeset
193 purple_connection_error(js->gc,
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21151
diff changeset
194 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE,
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
195 _("Server does not use any supported authentication method"));
28855
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
196 return;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
197 }
28855
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
198
29084
3a821d391ac0 Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <darkrain42@pidgin.im>
parents: 29008
diff changeset
199 state = js->auth_mech->start(js, mechs, &response, &msg);
3a821d391ac0 Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <darkrain42@pidgin.im>
parents: 29008
diff changeset
200 if (state == JABBER_SASL_STATE_FAIL) {
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 30898
diff changeset
201 purple_connection_error(js->gc,
29084
3a821d391ac0 Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <darkrain42@pidgin.im>
parents: 29008
diff changeset
202 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE,
3a821d391ac0 Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <darkrain42@pidgin.im>
parents: 29008
diff changeset
203 msg ? msg : _("Unknown Error"));
3a821d391ac0 Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <darkrain42@pidgin.im>
parents: 29008
diff changeset
204 } else if (response) {
28855
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
205 jabber_send(js, response);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
206 purple_xmlnode_free(response);
28855
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
207 }
29090
b351fcdeede7 jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <darkrain42@pidgin.im>
parents: 29084
diff changeset
208
b351fcdeede7 jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <darkrain42@pidgin.im>
parents: 29084
diff changeset
209 g_free(msg);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
210 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
211
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
212 static void auth_old_result_cb(JabberStream *js, const char *from,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
213 JabberIqType type, const char *id,
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
214 PurpleXmlNode *packet, gpointer data)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
215 {
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
216 if (type == JABBER_IQ_RESULT) {
28379
df144a809a92 jabber: Fix using BOSH and legacy auth together. Closes #9990.
Paul Aurich <darkrain42@pidgin.im>
parents: 28322
diff changeset
217 jabber_stream_set_state(js, JABBER_STREAM_POST_AUTH);
26669
eabe41a84e13 Fix login process for older servers using IQ-auth.
Paul Aurich <darkrain42@pidgin.im>
parents: 26533
diff changeset
218 jabber_disco_items_server(js);
7730
b7280ceae395 [gaim-migrate @ 8375]
Nathan Walp <nwalp@pidgin.im>
parents: 7704
diff changeset
219 } else {
28856
992b7074357d jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <darkrain42@pidgin.im>
parents: 28855
diff changeset
220 PurpleAccount *account;
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21151
diff changeset
221 PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR;
21150
bedd1215fb5e Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents: 20882
diff changeset
222 char *msg = jabber_parse_error(js, packet, &reason);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
223 PurpleXmlNode *error;
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8397
diff changeset
224 const char *err_code;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
225
28858
defe5e7f076a Speilling!
Paul Aurich <darkrain42@pidgin.im>
parents: 28857
diff changeset
226 account = purple_connection_get_account(js->gc);
28856
992b7074357d jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <darkrain42@pidgin.im>
parents: 28855
diff changeset
227
21150
bedd1215fb5e Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents: 20882
diff changeset
228 /* FIXME: Why is this not in jabber_parse_error? */
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
229 if((error = purple_xmlnode_get_child(packet, "error")) &&
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
230 (err_code = purple_xmlnode_get_attrib(error, "code")) &&
28829
3f69866415b4 jabber: Use purple_strequal to simplify some auth code
Paul Aurich <darkrain42@pidgin.im>
parents: 28828
diff changeset
231 g_str_equal(err_code, "401")) {
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21151
diff changeset
232 reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED;
19993
867bd1dfe680 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 <datallah@pidgin.im>
parents: 19859
diff changeset
233 /* Clear the pasword if it isn't being saved */
28856
992b7074357d jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <darkrain42@pidgin.im>
parents: 28855
diff changeset
234 if (!purple_account_get_remember_password(account))
34029
059c1270db1f Remove the silly destroy argument from purple_account_set_password and
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 34028
diff changeset
235 purple_account_set_password(account, NULL, NULL, NULL);
7730
b7280ceae395 [gaim-migrate @ 8375]
Nathan Walp <nwalp@pidgin.im>
parents: 7704
diff changeset
236 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
237
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 30898
diff changeset
238 purple_connection_error(js->gc, reason, msg);
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8397
diff changeset
239 g_free(msg);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
240 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
241 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
242
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
243 static void auth_old_cb(JabberStream *js, const char *from,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
244 JabberIqType type, const char *id,
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
245 PurpleXmlNode *packet, gpointer data)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
246 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
247 JabberIq *iq;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
248 PurpleXmlNode *query, *x;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
249 const char *pw = purple_connection_get_password(js->gc);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
250
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
251 if (type == JABBER_IQ_ERROR) {
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21151
diff changeset
252 PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR;
21150
bedd1215fb5e Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents: 20882
diff changeset
253 char *msg = jabber_parse_error(js, packet, &reason);
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 30898
diff changeset
254 purple_connection_error(js->gc, reason, msg);
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8397
diff changeset
255 g_free(msg);
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
256 } else if (type == JABBER_IQ_RESULT) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
257 query = purple_xmlnode_get_child(packet, "query");
30741
08f776e14719 jabber: Slight improvements to the stream ID fix
Paul Aurich <darkrain42@pidgin.im>
parents: 30740
diff changeset
258 if (js->stream_id && *js->stream_id &&
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
259 purple_xmlnode_get_child(query, "digest")) {
25110
40b3fffdb00b Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <darkrain42@pidgin.im>
parents: 24830
diff changeset
260 char *s, *hash;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
261
8397
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
262 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:auth");
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
263 query = purple_xmlnode_get_child(iq->node, "query");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
264 x = purple_xmlnode_new_child(query, "username");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
265 purple_xmlnode_insert_data(x, js->user->node, -1);
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
266 x = purple_xmlnode_new_child(query, "resource");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
267 purple_xmlnode_insert_data(x, js->user->resource, -1);
8397
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
268
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
269 x = purple_xmlnode_new_child(query, "digest");
7514
bfea1665a240 [gaim-migrate @ 8127]
Nathan Walp <nwalp@pidgin.im>
parents: 7425
diff changeset
270 s = g_strdup_printf("%s%s", js->stream_id, pw);
29910
f1c6e586e5c1 jabber: Validate the hash on incoming BoB objects (in case the CID is on the
Marcus Lundblad <malu@pidgin.im>
parents: 29196
diff changeset
271 hash = jabber_calculate_data_hash(s, strlen(s), "sha1");
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
272 purple_xmlnode_insert_data(x, hash, -1);
25110
40b3fffdb00b Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <darkrain42@pidgin.im>
parents: 24830
diff changeset
273 g_free(hash);
7514
bfea1665a240 [gaim-migrate @ 8127]
Nathan Walp <nwalp@pidgin.im>
parents: 7425
diff changeset
274 g_free(s);
8397
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
275 jabber_iq_set_callback(iq, auth_old_result_cb, NULL);
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
276 jabber_iq_send(iq);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
277 } else if ((x = purple_xmlnode_get_child(query, "crammd5"))) {
30741
08f776e14719 jabber: Slight improvements to the stream ID fix
Paul Aurich <darkrain42@pidgin.im>
parents: 30740
diff changeset
278 /* For future reference, this appears to be a custom OS X extension
08f776e14719 jabber: Slight improvements to the stream ID fix
Paul Aurich <darkrain42@pidgin.im>
parents: 30740
diff changeset
279 * to non-SASL authentication.
08f776e14719 jabber: Slight improvements to the stream ID fix
Paul Aurich <darkrain42@pidgin.im>
parents: 30740
diff changeset
280 */
21967
3f1c1518a7e1 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents: 21966
diff changeset
281 const char *challenge;
23407
6f89ce4acd7a A patch from QuLogic to eliminate duplicated HMAC-MD5 code in the Jabber
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23399
diff changeset
282 gchar digest[33];
34567
ea5103f66b0e Refactor the codebase to use PurpleHash
Ankit Vani <a@nevitus.org>
parents: 34556
diff changeset
283 PurpleCipher *hmac;
ea5103f66b0e Refactor the codebase to use PurpleHash
Ankit Vani <a@nevitus.org>
parents: 34556
diff changeset
284 PurpleHash *md5;
21967
3f1c1518a7e1 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents: 21966
diff changeset
285
23407
6f89ce4acd7a A patch from QuLogic to eliminate duplicated HMAC-MD5 code in the Jabber
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23399
diff changeset
286 /* Calculate the MHAC-MD5 digest */
34567
ea5103f66b0e Refactor the codebase to use PurpleHash
Ankit Vani <a@nevitus.org>
parents: 34556
diff changeset
287 md5 = purple_md5_hash_new();
34556
087db73b115d Refactored protocols bonjour, gg, jabber to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 34175
diff changeset
288 hmac = purple_hmac_cipher_new(md5);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
289 challenge = purple_xmlnode_get_attrib(x, "challenge");
34556
087db73b115d Refactored protocols bonjour, gg, jabber to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 34175
diff changeset
290 purple_cipher_set_key(hmac, (guchar *)pw, strlen(pw));
087db73b115d Refactored protocols bonjour, gg, jabber to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 34175
diff changeset
291 purple_cipher_append(hmac, (guchar *)challenge, strlen(challenge));
087db73b115d Refactored protocols bonjour, gg, jabber to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 34175
diff changeset
292 purple_cipher_digest_to_str(hmac, digest, 33);
087db73b115d Refactored protocols bonjour, gg, jabber to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 34175
diff changeset
293 g_object_unref(hmac);
087db73b115d Refactored protocols bonjour, gg, jabber to use the GObject-based PurpleCipher
Ankit Vani <a@nevitus.org>
parents: 34175
diff changeset
294 g_object_unref(md5);
21969
9386fcc30b22 Last minute 'cleanup' actually resulted in breakage on my cram-md5 commit. Fixed it.
Evan Schoenberg <evands@pidgin.im>
parents: 21967
diff changeset
295
9386fcc30b22 Last minute 'cleanup' actually resulted in breakage on my cram-md5 commit. Fixed it.
Evan Schoenberg <evands@pidgin.im>
parents: 21967
diff changeset
296 /* Create the response query */
21967
3f1c1518a7e1 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents: 21966
diff changeset
297 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:auth");
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
298 query = purple_xmlnode_get_child(iq->node, "query");
21967
3f1c1518a7e1 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents: 21966
diff changeset
299
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
300 x = purple_xmlnode_new_child(query, "username");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
301 purple_xmlnode_insert_data(x, js->user->node, -1);
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
302 x = purple_xmlnode_new_child(query, "resource");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
303 purple_xmlnode_insert_data(x, js->user->resource, -1);
21967
3f1c1518a7e1 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents: 21966
diff changeset
304
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
305 x = purple_xmlnode_new_child(query, "crammd5");
21967
3f1c1518a7e1 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents: 21966
diff changeset
306
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
307 purple_xmlnode_insert_data(x, digest, 32);
21967
3f1c1518a7e1 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents: 21966
diff changeset
308
3f1c1518a7e1 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents: 21966
diff changeset
309 jabber_iq_set_callback(iq, auth_old_result_cb, NULL);
3f1c1518a7e1 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents: 21966
diff changeset
310 jabber_iq_send(iq);
3f1c1518a7e1 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents: 21966
diff changeset
311
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
312 } else if(purple_xmlnode_get_child(query, "password")) {
28856
992b7074357d jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <darkrain42@pidgin.im>
parents: 28855
diff changeset
313 PurpleAccount *account = purple_connection_get_account(js->gc);
992b7074357d jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <darkrain42@pidgin.im>
parents: 28855
diff changeset
314 if(!jabber_stream_is_ssl(js) && !purple_account_get_bool(account,
8397
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
315 "auth_plain_in_clear", FALSE)) {
22815
a352aba19309 The warning string for plaintext auth over an unencrypted connection is found
Evan Schoenberg <evands@pidgin.im>
parents: 22802
diff changeset
316 char *msg = g_strdup_printf(_("%s requires plaintext authentication over an unencrypted connection. Allow this and continue authentication?"),
28856
992b7074357d jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <darkrain42@pidgin.im>
parents: 28855
diff changeset
317 purple_account_get_username(account));
21175
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
318 purple_request_yes_no(js->gc, _("Plaintext Authentication"),
8397
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
319 _("Plaintext Authentication"),
22815
a352aba19309 The warning string for plaintext auth over an unencrypted connection is found
Evan Schoenberg <evands@pidgin.im>
parents: 22802
diff changeset
320 msg,
22269
3fdf7b13f20a A few more of those "default_action" fixes
Mark Doliner <markdoliner@pidgin.im>
parents: 22068
diff changeset
321 1,
34331
c8486462bb63 Request API refactoring: switch purple_request_action to PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents: 34175
diff changeset
322 purple_request_cpar_from_account(account),
28856
992b7074357d jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <darkrain42@pidgin.im>
parents: 28855
diff changeset
323 account, allow_plaintext_auth,
21175
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
324 disallow_plaintext_auth);
22815
a352aba19309 The warning string for plaintext auth over an unencrypted connection is found
Evan Schoenberg <evands@pidgin.im>
parents: 22802
diff changeset
325 g_free(msg);
8397
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
326 return;
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
327 }
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
328 finish_plaintext_authentication(js);
7514
bfea1665a240 [gaim-migrate @ 8127]
Nathan Walp <nwalp@pidgin.im>
parents: 7425
diff changeset
329 } else {
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 30898
diff changeset
330 purple_connection_error(js->gc,
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21151
diff changeset
331 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE,
20445
c900767c024b Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents: 19993
diff changeset
332 _("Server does not use any supported authentication method"));
8397
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
333 return;
7514
bfea1665a240 [gaim-migrate @ 8127]
Nathan Walp <nwalp@pidgin.im>
parents: 7425
diff changeset
334 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
335 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
336 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
337
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
338 void jabber_auth_start_old(JabberStream *js)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
339 {
28856
992b7074357d jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <darkrain42@pidgin.im>
parents: 28855
diff changeset
340 PurpleAccount *account;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
341 JabberIq *iq;
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
342 PurpleXmlNode *query, *username;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
343
28856
992b7074357d jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <darkrain42@pidgin.im>
parents: 28855
diff changeset
344 account = purple_connection_get_account(js->gc);
992b7074357d jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <darkrain42@pidgin.im>
parents: 28855
diff changeset
345
28583
03f8fee2908a jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <darkrain42@pidgin.im>
parents: 28379
diff changeset
346 /*
03f8fee2908a jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <darkrain42@pidgin.im>
parents: 28379
diff changeset
347 * We can end up here without encryption if the server doesn't support
27170
447ef31d038a Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <darkrain42@pidgin.im>
parents: 26707
diff changeset
348 * <stream:features/> and we're not using old-style SSL. If the user
447ef31d038a Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <darkrain42@pidgin.im>
parents: 26707
diff changeset
349 * is requiring SSL/TLS, we need to enforce it.
447ef31d038a Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <darkrain42@pidgin.im>
parents: 26707
diff changeset
350 */
447ef31d038a Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <darkrain42@pidgin.im>
parents: 26707
diff changeset
351 if (!jabber_stream_is_ssl(js) &&
30740
017077f79a0f jabber: Unify "Require TLS" and "Use old-style (port 5223) SSL" settings
Paul Aurich <darkrain42@pidgin.im>
parents: 30708
diff changeset
352 g_str_equal("require_tls",
017077f79a0f jabber: Unify "Require TLS" and "Use old-style (port 5223) SSL" settings
Paul Aurich <darkrain42@pidgin.im>
parents: 30708
diff changeset
353 purple_account_get_string(account, "connection_security", JABBER_DEFAULT_REQUIRE_TLS))) {
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 30898
diff changeset
354 purple_connection_error(js->gc,
27170
447ef31d038a Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <darkrain42@pidgin.im>
parents: 26707
diff changeset
355 PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR,
447ef31d038a Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <darkrain42@pidgin.im>
parents: 26707
diff changeset
356 _("You require encryption, but it is not available on this server."));
447ef31d038a Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <darkrain42@pidgin.im>
parents: 26707
diff changeset
357 return;
447ef31d038a Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <darkrain42@pidgin.im>
parents: 26707
diff changeset
358 }
447ef31d038a Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <darkrain42@pidgin.im>
parents: 26707
diff changeset
359
28855
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
360 if (js->registration) {
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
361 jabber_register_start(js);
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
362 return;
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
363 }
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
364
28583
03f8fee2908a jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <darkrain42@pidgin.im>
parents: 28379
diff changeset
365 /*
03f8fee2908a jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <darkrain42@pidgin.im>
parents: 28379
diff changeset
366 * IQ Auth doesn't have support for resource binding, so we need to pick a
03f8fee2908a jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <darkrain42@pidgin.im>
parents: 28379
diff changeset
367 * default resource so it will work properly. jabberd14 throws an error and
03f8fee2908a jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <darkrain42@pidgin.im>
parents: 28379
diff changeset
368 * iChat server just fails silently.
03f8fee2908a jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <darkrain42@pidgin.im>
parents: 28379
diff changeset
369 */
03f8fee2908a jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <darkrain42@pidgin.im>
parents: 28379
diff changeset
370 if (!js->user->resource || *js->user->resource == '\0') {
03f8fee2908a jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <darkrain42@pidgin.im>
parents: 28379
diff changeset
371 g_free(js->user->resource);
03f8fee2908a jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <darkrain42@pidgin.im>
parents: 28379
diff changeset
372 js->user->resource = g_strdup("Home");
03f8fee2908a jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <darkrain42@pidgin.im>
parents: 28379
diff changeset
373 }
03f8fee2908a jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <darkrain42@pidgin.im>
parents: 28379
diff changeset
374
16180
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
375 #ifdef HAVE_CYRUS_SASL
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
376 /* If we have Cyrus SASL, then passwords will have been set
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
377 * to OPTIONAL for this protocol. So, we need to do our own
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
378 * password prompting here
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
379 */
20093
04f3c1dcd2cf applied changes from 5fda75104115d0a95c1e214b6b3ca18c4dc86a0c
Richard Laager <rlaager@pidgin.im>
parents: 19993
diff changeset
380
34022
c49f6e9ea27d Make all the prpls build.
Paul Aurich <darkrain42@pidgin.im>
parents: 28379
diff changeset
381 if (!purple_connection_get_password(js->gc)) {
28856
992b7074357d jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <darkrain42@pidgin.im>
parents: 28855
diff changeset
382 purple_account_request_password(account, G_CALLBACK(auth_old_pass_cb), G_CALLBACK(auth_no_pass_cb), js->gc);
16180
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
383 return;
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
384 }
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
385 #endif
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
386 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:auth");
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
387
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
388 query = purple_xmlnode_get_child(iq->node, "query");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
389 username = purple_xmlnode_new_child(query, "username");
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
390 purple_xmlnode_insert_data(username, js->user->node, -1);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
391
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7291
diff changeset
392 jabber_iq_set_callback(iq, auth_old_cb, NULL);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
393
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
394 jabber_iq_send(iq);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
395 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
396
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
397 void
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
398 jabber_auth_handle_challenge(JabberStream *js, PurpleXmlNode *packet)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
399 {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
400 const char *ns = purple_xmlnode_get_namespace(packet);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
401
29008
1f288722b5cd jabber: Use NS_XMPP_SASL
Paul Aurich <darkrain42@pidgin.im>
parents: 28866
diff changeset
402 if (!purple_strequal(ns, NS_XMPP_SASL)) {
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 30898
diff changeset
403 purple_connection_error(js->gc,
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21151
diff changeset
404 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
27635
0cd19038c417 More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents: 27633
diff changeset
405 _("Invalid response from server"));
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
406 return;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
407 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
408
28855
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
409 if (js->auth_mech && js->auth_mech->handle_challenge) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
410 PurpleXmlNode *response = NULL;
29090
b351fcdeede7 jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <darkrain42@pidgin.im>
parents: 29084
diff changeset
411 char *msg = NULL;
29084
3a821d391ac0 Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <darkrain42@pidgin.im>
parents: 29008
diff changeset
412 JabberSaslState state = js->auth_mech->handle_challenge(js, packet, &response, &msg);
3a821d391ac0 Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <darkrain42@pidgin.im>
parents: 29008
diff changeset
413 if (state == JABBER_SASL_STATE_FAIL) {
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 30898
diff changeset
414 purple_connection_error(js->gc,
29084
3a821d391ac0 Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <darkrain42@pidgin.im>
parents: 29008
diff changeset
415 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE,
3a821d391ac0 Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <darkrain42@pidgin.im>
parents: 29008
diff changeset
416 msg ? msg : _("Invalid challenge from server"));
3a821d391ac0 Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <darkrain42@pidgin.im>
parents: 29008
diff changeset
417 } else if (response) {
28855
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
418 jabber_send(js, response);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
419 purple_xmlnode_free(response);
28855
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
420 }
29090
b351fcdeede7 jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <darkrain42@pidgin.im>
parents: 29084
diff changeset
421
b351fcdeede7 jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <darkrain42@pidgin.im>
parents: 29084
diff changeset
422 g_free(msg);
28855
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
423 } else
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
424 purple_debug_warning("jabber", "Received unexpected (and unhandled) <challenge/>\n");
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
425 }
15170
2a272f828453 [gaim-migrate @ 17894]
Nathan Walp <nwalp@pidgin.im>
parents: 15143
diff changeset
426
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
427 void jabber_auth_handle_success(JabberStream *js, PurpleXmlNode *packet)
28855
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
428 {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
429 const char *ns = purple_xmlnode_get_namespace(packet);
15170
2a272f828453 [gaim-migrate @ 17894]
Nathan Walp <nwalp@pidgin.im>
parents: 15143
diff changeset
430
29008
1f288722b5cd jabber: Use NS_XMPP_SASL
Paul Aurich <darkrain42@pidgin.im>
parents: 28866
diff changeset
431 if (!purple_strequal(ns, NS_XMPP_SASL)) {
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 30898
diff changeset
432 purple_connection_error(js->gc,
28855
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
433 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
434 _("Invalid response from server"));
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
435 return;
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
436 }
28855
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
437
29084
3a821d391ac0 Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <darkrain42@pidgin.im>
parents: 29008
diff changeset
438 if (js->auth_mech && js->auth_mech->handle_success) {
29090
b351fcdeede7 jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <darkrain42@pidgin.im>
parents: 29084
diff changeset
439 char *msg = NULL;
29084
3a821d391ac0 Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <darkrain42@pidgin.im>
parents: 29008
diff changeset
440 JabberSaslState state = js->auth_mech->handle_success(js, packet, &msg);
3a821d391ac0 Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <darkrain42@pidgin.im>
parents: 29008
diff changeset
441
3a821d391ac0 Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <darkrain42@pidgin.im>
parents: 29008
diff changeset
442 if (state == JABBER_SASL_STATE_FAIL) {
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 30898
diff changeset
443 purple_connection_error(js->gc,
29084
3a821d391ac0 Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <darkrain42@pidgin.im>
parents: 29008
diff changeset
444 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE,
3a821d391ac0 Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <darkrain42@pidgin.im>
parents: 29008
diff changeset
445 msg ? msg : _("Invalid response from server"));
3a821d391ac0 Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <darkrain42@pidgin.im>
parents: 29008
diff changeset
446 return;
3a821d391ac0 Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <darkrain42@pidgin.im>
parents: 29008
diff changeset
447 } else if (state == JABBER_SASL_STATE_CONTINUE) {
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 30898
diff changeset
448 purple_connection_error(js->gc,
29084
3a821d391ac0 Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <darkrain42@pidgin.im>
parents: 29008
diff changeset
449 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE,
3a821d391ac0 Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <darkrain42@pidgin.im>
parents: 29008
diff changeset
450 msg ? msg : _("Server thinks authentication is complete, but client does not"));
3a821d391ac0 Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <darkrain42@pidgin.im>
parents: 29008
diff changeset
451 return;
3a821d391ac0 Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <darkrain42@pidgin.im>
parents: 29008
diff changeset
452 }
29090
b351fcdeede7 jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <darkrain42@pidgin.im>
parents: 29084
diff changeset
453
b351fcdeede7 jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <darkrain42@pidgin.im>
parents: 29084
diff changeset
454 g_free(msg);
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
455 }
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
456
28379
df144a809a92 jabber: Fix using BOSH and legacy auth together. Closes #9990.
Paul Aurich <darkrain42@pidgin.im>
parents: 28322
diff changeset
457 /*
df144a809a92 jabber: Fix using BOSH and legacy auth together. Closes #9990.
Paul Aurich <darkrain42@pidgin.im>
parents: 28322
diff changeset
458 * The stream will be reinitialized later in jabber_recv_cb_ssl() or
df144a809a92 jabber: Fix using BOSH and legacy auth together. Closes #9990.
Paul Aurich <darkrain42@pidgin.im>
parents: 28322
diff changeset
459 * jabber_bosh_connection_send.
df144a809a92 jabber: Fix using BOSH and legacy auth together. Closes #9990.
Paul Aurich <darkrain42@pidgin.im>
parents: 28322
diff changeset
460 */
df144a809a92 jabber: Fix using BOSH and legacy auth together. Closes #9990.
Paul Aurich <darkrain42@pidgin.im>
parents: 28322
diff changeset
461 js->reinit = TRUE;
df144a809a92 jabber: Fix using BOSH and legacy auth together. Closes #9990.
Paul Aurich <darkrain42@pidgin.im>
parents: 28322
diff changeset
462 jabber_stream_set_state(js, JABBER_STREAM_POST_AUTH);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
463 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
464
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
465 void jabber_auth_handle_failure(JabberStream *js, PurpleXmlNode *packet)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
466 {
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21151
diff changeset
467 PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR;
29090
b351fcdeede7 jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <darkrain42@pidgin.im>
parents: 29084
diff changeset
468 char *msg = NULL;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
469
28855
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
470 if (js->auth_mech && js->auth_mech->handle_failure) {
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
471 PurpleXmlNode *stanza = NULL;
29084
3a821d391ac0 Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <darkrain42@pidgin.im>
parents: 29008
diff changeset
472 JabberSaslState state = js->auth_mech->handle_failure(js, packet, &stanza, &msg);
3a821d391ac0 Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <darkrain42@pidgin.im>
parents: 29008
diff changeset
473
29196
4bd9e71f7b09 Cyrus may not have anything (yet) if it's waiting for a callback or something.
Paul Aurich <darkrain42@pidgin.im>
parents: 29090
diff changeset
474 if (state != JABBER_SASL_STATE_FAIL) {
4bd9e71f7b09 Cyrus may not have anything (yet) if it's waiting for a callback or something.
Paul Aurich <darkrain42@pidgin.im>
parents: 29090
diff changeset
475 if (stanza) {
4bd9e71f7b09 Cyrus may not have anything (yet) if it's waiting for a callback or something.
Paul Aurich <darkrain42@pidgin.im>
parents: 29090
diff changeset
476 jabber_send(js, stanza);
34935
686fa55b0deb Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents: 34567
diff changeset
477 purple_xmlnode_free(stanza);
29196
4bd9e71f7b09 Cyrus may not have anything (yet) if it's waiting for a callback or something.
Paul Aurich <darkrain42@pidgin.im>
parents: 29090
diff changeset
478 }
4bd9e71f7b09 Cyrus may not have anything (yet) if it's waiting for a callback or something.
Paul Aurich <darkrain42@pidgin.im>
parents: 29090
diff changeset
479
22913
d0ecc309dc42 After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evands@pidgin.im>
parents: 22815
diff changeset
480 return;
d0ecc309dc42 After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evands@pidgin.im>
parents: 22815
diff changeset
481 }
22800
0288a22eb85a 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 <nosnilmot@pidgin.im>
parents: 22667
diff changeset
482 }
28855
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
483
29090
b351fcdeede7 jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <darkrain42@pidgin.im>
parents: 29084
diff changeset
484 if (!msg)
b351fcdeede7 jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <darkrain42@pidgin.im>
parents: 29084
diff changeset
485 msg = jabber_parse_error(js, packet, &reason);
b351fcdeede7 jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <darkrain42@pidgin.im>
parents: 29084
diff changeset
486
b351fcdeede7 jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <darkrain42@pidgin.im>
parents: 29084
diff changeset
487 if (!msg) {
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 30898
diff changeset
488 purple_connection_error(js->gc,
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21151
diff changeset
489 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
27635
0cd19038c417 More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents: 27633
diff changeset
490 _("Invalid response from server"));
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8397
diff changeset
491 } else {
32157
39ba2e2492ee Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents: 30898
diff changeset
492 purple_connection_error(js->gc, reason, msg);
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8397
diff changeset
493 g_free(msg);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
494 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
495 }
28855
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
496
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
497 static gint compare_mech(gconstpointer a, gconstpointer b)
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
498 {
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
499 const JabberSaslMech *mech_a = a;
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
500 const JabberSaslMech *mech_b = b;
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
501
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
502 /* higher priority comes *before* lower priority in the list */
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
503 if (mech_a->priority > mech_b->priority)
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
504 return -1;
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
505 else if (mech_a->priority < mech_b->priority)
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
506 return 1;
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
507 /* This really shouldn't happen */
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
508 return 0;
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
509 }
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
510
30898
f7c884a1c8ff jabber: Add abstraction functions for adding/removing auth mechs. Closes #12715
Eion Robb <eion@robbmob.com>
parents: 30741
diff changeset
511 void jabber_auth_add_mech(JabberSaslMech *mech)
f7c884a1c8ff jabber: Add abstraction functions for adding/removing auth mechs. Closes #12715
Eion Robb <eion@robbmob.com>
parents: 30741
diff changeset
512 {
f7c884a1c8ff jabber: Add abstraction functions for adding/removing auth mechs. Closes #12715
Eion Robb <eion@robbmob.com>
parents: 30741
diff changeset
513 auth_mechs = g_slist_insert_sorted(auth_mechs, mech, compare_mech);
f7c884a1c8ff jabber: Add abstraction functions for adding/removing auth mechs. Closes #12715
Eion Robb <eion@robbmob.com>
parents: 30741
diff changeset
514 }
f7c884a1c8ff jabber: Add abstraction functions for adding/removing auth mechs. Closes #12715
Eion Robb <eion@robbmob.com>
parents: 30741
diff changeset
515
f7c884a1c8ff jabber: Add abstraction functions for adding/removing auth mechs. Closes #12715
Eion Robb <eion@robbmob.com>
parents: 30741
diff changeset
516 void jabber_auth_remove_mech(JabberSaslMech *mech)
f7c884a1c8ff jabber: Add abstraction functions for adding/removing auth mechs. Closes #12715
Eion Robb <eion@robbmob.com>
parents: 30741
diff changeset
517 {
f7c884a1c8ff jabber: Add abstraction functions for adding/removing auth mechs. Closes #12715
Eion Robb <eion@robbmob.com>
parents: 30741
diff changeset
518 auth_mechs = g_slist_remove(auth_mechs, mech);
f7c884a1c8ff jabber: Add abstraction functions for adding/removing auth mechs. Closes #12715
Eion Robb <eion@robbmob.com>
parents: 30741
diff changeset
519 }
f7c884a1c8ff jabber: Add abstraction functions for adding/removing auth mechs. Closes #12715
Eion Robb <eion@robbmob.com>
parents: 30741
diff changeset
520
28855
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
521 void jabber_auth_init(void)
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
522 {
28866
e3d867ce000b jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <darkrain42@pidgin.im>
parents: 28858
diff changeset
523 JabberSaslMech **tmp;
e3d867ce000b jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <darkrain42@pidgin.im>
parents: 28858
diff changeset
524 gint count, i;
e3d867ce000b jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <darkrain42@pidgin.im>
parents: 28858
diff changeset
525
30898
f7c884a1c8ff jabber: Add abstraction functions for adding/removing auth mechs. Closes #12715
Eion Robb <eion@robbmob.com>
parents: 30741
diff changeset
526 jabber_auth_add_mech(jabber_auth_get_plain_mech());
f7c884a1c8ff jabber: Add abstraction functions for adding/removing auth mechs. Closes #12715
Eion Robb <eion@robbmob.com>
parents: 30741
diff changeset
527 jabber_auth_add_mech(jabber_auth_get_digest_md5_mech());
28855
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
528 #ifdef HAVE_CYRUS_SASL
30898
f7c884a1c8ff jabber: Add abstraction functions for adding/removing auth mechs. Closes #12715
Eion Robb <eion@robbmob.com>
parents: 30741
diff changeset
529 jabber_auth_add_mech(jabber_auth_get_cyrus_mech());
28855
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
530 #endif
28866
e3d867ce000b jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <darkrain42@pidgin.im>
parents: 28858
diff changeset
531
e3d867ce000b jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <darkrain42@pidgin.im>
parents: 28858
diff changeset
532 tmp = jabber_auth_get_scram_mechs(&count);
e3d867ce000b jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <darkrain42@pidgin.im>
parents: 28858
diff changeset
533 for (i = 0; i < count; ++i)
30898
f7c884a1c8ff jabber: Add abstraction functions for adding/removing auth mechs. Closes #12715
Eion Robb <eion@robbmob.com>
parents: 30741
diff changeset
534 jabber_auth_add_mech(tmp[i]);
28855
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
535 }
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
536
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
537 void jabber_auth_uninit(void)
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
538 {
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
539 g_slist_free(auth_mechs);
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
540 auth_mechs = NULL;
c5bc85f9c00e jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents: 28835
diff changeset
541 }

mercurial