annotate libpurple/protocols/jabber/auth.c @ 28520:682b441d4944

Hmm, I think I'm reaching diminishing returns.
author Paul Aurich <paul@darkrain42.org>
date Fri, 06 Nov 2009 09:57:49 +0000
parents 18b64ff28354
children 8ada06fb65ed
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
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
42 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
43 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
44 xmlnode *packet, gpointer data);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46 gboolean
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47 jabber_process_starttls(JabberStream *js, xmlnode *packet)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 xmlnode *starttls;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51 if((starttls = xmlnode_get_child(packet, "starttls"))) {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
52 if(purple_ssl_is_supported()) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 jabber_send_raw(js,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 "<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>", -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 return TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 } else if(xmlnode_get_child(starttls, "required")) {
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
57 purple_connection_error_reason(js->gc,
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
58 PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT,
27378
6275df9d2d62 Change strings in libpurple/protocols/jabber/auth.c and util.c a little bit
Mark Doliner <mark@kingant.net>
parents: 27151
diff changeset
59 _("Server requires TLS/SSL, but no TLS/SSL support was found."));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60 return TRUE;
28515
4fd0baa32a9e jabber: Fix a few places where the default for require_tls was wrong.
Paul Aurich <paul@darkrain42.org>
parents: 28514
diff changeset
61 } else if(purple_account_get_bool(js->gc->account, "require_tls", JABBER_DEFAULT_REQUIRE_TLS)) {
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
62 purple_connection_error_reason(js->gc,
22800
abd261518b83 When an XMPP account is set to require TLS, but libpurple doesn't have SSL
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22672
diff changeset
63 PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT,
27378
6275df9d2d62 Change strings in libpurple/protocols/jabber/auth.c and util.c a little bit
Mark Doliner <mark@kingant.net>
parents: 27151
diff changeset
64 _("You require encryption, but no TLS/SSL support was found."));
22800
abd261518b83 When an XMPP account is set to require TLS, but libpurple doesn't have SSL
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22672
diff changeset
65 return TRUE;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69 return FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72 static void finish_plaintext_authentication(JabberStream *js)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
74 if(js->auth_type == JABBER_AUTH_PLAIN) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75 xmlnode *auth;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76 GString *response;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77 gchar *enc_out;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 auth = xmlnode_new("auth");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 xmlnode_set_namespace(auth, "urn:ietf:params:xml:ns:xmpp-sasl");
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
81
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82 xmlnode_set_attrib(auth, "xmlns:ga", "http://www.google.com/talk/protocol/auth");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83 xmlnode_set_attrib(auth, "ga:client-uses-full-bind-result", "true");
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
84
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85 response = g_string_new("");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
86 response = g_string_append_len(response, "\0", 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87 response = g_string_append(response, js->user->node);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88 response = g_string_append_len(response, "\0", 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89 response = g_string_append(response,
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
90 purple_connection_get_password(js->gc));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
91
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
92 enc_out = purple_base64_encode((guchar *)response->str, response->len);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
93
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94 xmlnode_set_attrib(auth, "mechanism", "PLAIN");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95 xmlnode_insert_data(auth, enc_out, -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
96 g_free(enc_out);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97 g_string_free(response, TRUE);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99 jabber_send(js, auth);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
100 xmlnode_free(auth);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
101 } else if(js->auth_type == JABBER_AUTH_IQ_AUTH) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
102 JabberIq *iq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
103 xmlnode *query, *x;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
104
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
105 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
106 query = xmlnode_get_child(iq->node, "query");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
107 x = xmlnode_new_child(query, "username");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
108 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
109 x = xmlnode_new_child(query, "resource");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110 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
111 x = xmlnode_new_child(query, "password");
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
112 xmlnode_insert_data(x, purple_connection_get_password(js->gc), -1);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113 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
114 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
115 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
118 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
119 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
120 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
121
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
122 finish_plaintext_authentication(account->gc->proto_data);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
125 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
126 {
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
127 purple_connection_error_reason(account->gc,
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
128 PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR,
20117
f24a2cacacd1 Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <will.thompson@collabora.co.uk>
parents: 19999
diff changeset
129 _("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
130 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
131
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132 #ifdef HAVE_CYRUS_SASL
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134 static void jabber_auth_start_cyrus(JabberStream *);
16068
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
135 static void jabber_sasl_build_callbacks(JabberStream *);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
136
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 /* Callbacks for Cyrus SASL */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139 static int jabber_sasl_cb_realm(void *ctx, int id, const char **avail, const char **result)
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 JabberStream *js = (JabberStream *)ctx;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
142
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
143 if (id != SASL_CB_GETREALM || !result) return SASL_BADPARAM;
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 *result = js->user->domain;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
147 return SASL_OK;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
148 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
149
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
150 static int jabber_sasl_cb_simple(void *ctx, int id, const char **res, unsigned *len)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
151 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
152 JabberStream *js = (JabberStream *)ctx;
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 switch(id) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
155 case SASL_CB_AUTHNAME:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
156 *res = js->user->node;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
157 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158 case SASL_CB_USER:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159 *res = "";
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
161 default:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
162 return SASL_BADPARAM;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
163 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
164 if (len) *len = strlen((char *)*res);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
165 return SASL_OK;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
166 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
167
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
168 static int jabber_sasl_cb_secret(sasl_conn_t *conn, void *ctx, int id, sasl_secret_t **secret)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170 JabberStream *js = (JabberStream *)ctx;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
171 const char *pw = purple_account_get_password(js->gc->account);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
172 size_t len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
173 static sasl_secret_t *x = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
174
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
175 if (!conn || !secret || id != SASL_CB_PASS)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
176 return SASL_BADPARAM;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
178 len = strlen(pw);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179 x = (sasl_secret_t *) realloc(x, sizeof(sasl_secret_t) + len);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181 if (!x)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182 return SASL_NOMEM;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
183
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184 x->len = len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185 strcpy((char*)x->data, pw);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
186
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
187 *secret = x;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
188 return SASL_OK;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
189 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
190
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
191 static void allow_cyrus_plaintext_auth(PurpleAccount *account)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
192 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
193 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
194
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
195 jabber_auth_start_cyrus(account->gc->proto_data);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
196 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
197
16068
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
198 static gboolean auth_pass_generic(JabberStream *js, PurpleRequestFields *fields)
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
199 {
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
200 const char *entry;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
201 gboolean remember;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
202
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
203 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
204 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
205
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
206 if (!entry || !*entry)
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
207 {
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
208 purple_notify_error(js->gc->account, NULL, _("Password is required to sign on."), NULL);
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
209 return FALSE;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
210 }
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
211
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
212 if (remember)
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
213 purple_account_set_remember_password(js->gc->account, TRUE);
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
214
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
215 purple_account_set_password(js->gc->account, entry);
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
216
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
217 return TRUE;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
218 }
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
219
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
220 static void auth_pass_cb(PurpleConnection *conn, PurpleRequestFields *fields)
16068
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
221 {
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
222 JabberStream *js;
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
223
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
224 /* The password prompt dialog doesn't get disposed if the account disconnects */
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
225 if (!PURPLE_CONNECTION_IS_VALID(conn))
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
226 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
227
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
228 js = conn->proto_data;
16068
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
229
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
230 if (!auth_pass_generic(js, fields))
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
231 return;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
232
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
233 /* Rebuild our callbacks as we now have a password to offer */
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
234 jabber_sasl_build_callbacks(js);
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
235
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
236 /* Restart our connection */
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
237 jabber_auth_start_cyrus(js);
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
238 }
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
239
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
240 static void
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
241 auth_old_pass_cb(PurpleConnection *conn, PurpleRequestFields *fields)
16068
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
242 {
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
243 JabberStream *js;
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
244
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
245 /* The password prompt dialog doesn't get disposed if the account disconnects */
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
246 if (!PURPLE_CONNECTION_IS_VALID(conn))
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
247 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
248
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
249 js = conn->proto_data;
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
250
16068
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
251 if (!auth_pass_generic(js, fields))
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
252 return;
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
253
16068
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
254 /* Restart our connection */
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
255 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
256 }
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
257
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
258
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
259 static void
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
260 auth_no_pass_cb(PurpleConnection *conn, PurpleRequestFields *fields)
16068
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
261 {
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
262 JabberStream *js;
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
263
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
264 /* The password prompt dialog doesn't get disposed if the account disconnects */
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
265 if (!PURPLE_CONNECTION_IS_VALID(conn))
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
266 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
267
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
268 js = conn->proto_data;
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
269
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
270 /* Disable the account as the user has canceled connecting */
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
271 purple_account_set_enabled(conn->account, 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
272 }
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
273
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
274 static void jabber_auth_start_cyrus(JabberStream *js)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
275 {
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
276 const char *clientout = NULL;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
277 char *enc_out;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
278 unsigned coutlen = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
279 xmlnode *auth;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
280 sasl_security_properties_t secprops;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
281 gboolean again;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
282 gboolean plaintext = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
283
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
284 /* Set up security properties and options */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
285 secprops.min_ssf = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
286 secprops.security_flags = SASL_SEC_NOANONYMOUS;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
287
26272
fcee93c74230 BOSH: For authentication purposes, HTTPS is equivalent to a secured JabberStream.
Paul Aurich <paul@darkrain42.org>
parents: 25952
diff changeset
288 if (!jabber_stream_is_ssl(js)) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
289 secprops.max_ssf = -1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
290 secprops.maxbufsize = 4096;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
291 plaintext = purple_account_get_bool(js->gc->account, "auth_plain_in_clear", FALSE);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
292 if (!plaintext)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
293 secprops.security_flags |= SASL_SEC_NOPLAINTEXT;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
294 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
295 secprops.max_ssf = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
296 secprops.maxbufsize = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
297 plaintext = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
298 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
299 secprops.property_names = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
300 secprops.property_values = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
301
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
302 do {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
303 again = FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
304
15765
51dd9ae01585 pass the correct domain to cyrus sasl (sf patch 1663064)
Nathan Walp <nwalp@pidgin.im>
parents: 15373
diff changeset
305 js->sasl_state = sasl_client_new("xmpp", js->serverFQDN, NULL, NULL, js->sasl_cb, 0, &js->sasl);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
306 if (js->sasl_state==SASL_OK) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
307 sasl_setprop(js->sasl, SASL_SEC_PROPS, &secprops);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
308 purple_debug_info("sasl", "Mechs found: %s\n", js->sasl_mechs->str);
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
309 js->sasl_state = sasl_client_start(js->sasl, js->sasl_mechs->str, NULL, &clientout, &coutlen, &js->current_mech);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
310 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
311 switch (js->sasl_state) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
312 /* Success */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
313 case SASL_OK:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
314 case SASL_CONTINUE:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
315 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
316 case SASL_NOMECH:
16068
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
317 /* No mechanisms have offered to help */
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
318
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
319 /* Firstly, if we don't have a password try
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
320 * to get one
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
321 */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
322
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
323 if (!purple_account_get_password(js->gc->account)) {
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
324 purple_account_request_password(js->gc->account, G_CALLBACK(auth_pass_cb), G_CALLBACK(auth_no_pass_cb), js->gc);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
325 return;
16068
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
326
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
327 /* If we've got a password, but aren't sending
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
328 * it in plaintext, see if we can turn on
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
329 * plaintext auth
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
330 */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
331 } else if (!plaintext) {
16994
5f557e708335 fixes #763
Nathan Walp <nwalp@pidgin.im>
parents: 16651
diff changeset
332 char *msg = g_strdup_printf(_("%s requires plaintext authentication over an unencrypted connection. Allow this and continue authentication?"),
17012
b713af8ae274 I changed my mind, this should display the whole account name
Nathan Walp <nwalp@pidgin.im>
parents: 16994
diff changeset
333 js->gc->account->username);
21099
51cf02dbdb0e disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents: 21095
diff changeset
334 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
335 _("Plaintext Authentication"),
16994
5f557e708335 fixes #763
Nathan Walp <nwalp@pidgin.im>
parents: 16651
diff changeset
336 msg,
22143
70fc60344317 A few more of those "default_action" fixes
Mark Doliner <mark@kingant.net>
parents: 21949
diff changeset
337 1, js->gc->account, NULL, NULL, js->gc->account,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
338 allow_cyrus_plaintext_auth,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
339 disallow_plaintext_auth);
16994
5f557e708335 fixes #763
Nathan Walp <nwalp@pidgin.im>
parents: 16651
diff changeset
340 g_free(msg);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
341 return;
21853
c95eaf2ae085 If no sasl mechs are appropriate, attempt a jabber:iq:auth connection. Note that this isn't the same as a failed authentication over sasl. Detailed comments in the code regarding my reasoning for this behavior.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21560
diff changeset
342
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
343 } else {
21853
c95eaf2ae085 If no sasl mechs are appropriate, attempt a jabber:iq:auth connection. Note that this isn't the same as a failed authentication over sasl. Detailed comments in the code regarding my reasoning for this behavior.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21560
diff changeset
344 /* We have no mechs which can work.
c95eaf2ae085 If no sasl mechs are appropriate, attempt a jabber:iq:auth connection. Note that this isn't the same as a failed authentication over sasl. Detailed comments in the code regarding my reasoning for this behavior.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21560
diff changeset
345 * Try falling back on the old jabber:iq:auth method. We get here if the server supports
c95eaf2ae085 If no sasl mechs are appropriate, attempt a jabber:iq:auth connection. Note that this isn't the same as a failed authentication over sasl. Detailed comments in the code regarding my reasoning for this behavior.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21560
diff changeset
346 * one or more sasl mechs, we are compiled with cyrus-sasl support, but we support or can connect with none of
c95eaf2ae085 If no sasl mechs are appropriate, attempt a jabber:iq:auth connection. Note that this isn't the same as a failed authentication over sasl. Detailed comments in the code regarding my reasoning for this behavior.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21560
diff changeset
347 * the offerred mechs. jabberd 2.0 w/ SASL and Apple's iChat Server 10.5 both handle and expect
c95eaf2ae085 If no sasl mechs are appropriate, attempt a jabber:iq:auth connection. Note that this isn't the same as a failed authentication over sasl. Detailed comments in the code regarding my reasoning for this behavior.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21560
diff changeset
348 * jabber:iq:auth in this situation. iChat Server in particular offers SASL GSSAPI by default, which is often
c95eaf2ae085 If no sasl mechs are appropriate, attempt a jabber:iq:auth connection. Note that this isn't the same as a failed authentication over sasl. Detailed comments in the code regarding my reasoning for this behavior.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21560
diff changeset
349 * not configured on the client side, and expects a fallback to jabber:iq:auth when it (predictably) fails.
c95eaf2ae085 If no sasl mechs are appropriate, attempt a jabber:iq:auth connection. Note that this isn't the same as a failed authentication over sasl. Detailed comments in the code regarding my reasoning for this behavior.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21560
diff changeset
350 *
c95eaf2ae085 If no sasl mechs are appropriate, attempt a jabber:iq:auth connection. Note that this isn't the same as a failed authentication over sasl. Detailed comments in the code regarding my reasoning for this behavior.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21560
diff changeset
351 * Note: xep-0078 points out that using jabber:iq:auth after a sasl failure is wrong. However,
c95eaf2ae085 If no sasl mechs are appropriate, attempt a jabber:iq:auth connection. Note that this isn't the same as a failed authentication over sasl. Detailed comments in the code regarding my reasoning for this behavior.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21560
diff changeset
352 * I believe this refers to actual authentication failure, not a simple lack of concordant mechanisms.
c95eaf2ae085 If no sasl mechs are appropriate, attempt a jabber:iq:auth connection. Note that this isn't the same as a failed authentication over sasl. Detailed comments in the code regarding my reasoning for this behavior.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21560
diff changeset
353 * Doing otherwise means that simply compiling with SASL support renders the client unable to connect to servers
c95eaf2ae085 If no sasl mechs are appropriate, attempt a jabber:iq:auth connection. Note that this isn't the same as a failed authentication over sasl. Detailed comments in the code regarding my reasoning for this behavior.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21560
diff changeset
354 * which would connect without issue otherwise. -evands
c95eaf2ae085 If no sasl mechs are appropriate, attempt a jabber:iq:auth connection. Note that this isn't the same as a failed authentication over sasl. Detailed comments in the code regarding my reasoning for this behavior.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21560
diff changeset
355 */
22207
b52f690502a4 If falling back on the old auth method for Jabber, be sure to set js->auth_type to JABBER_AUTH_IQ_AUTH.
Evan Schoenberg <evan.s@dreskin.net>
parents: 22143
diff changeset
356 js->auth_type = JABBER_AUTH_IQ_AUTH;
21853
c95eaf2ae085 If no sasl mechs are appropriate, attempt a jabber:iq:auth connection. Note that this isn't the same as a failed authentication over sasl. Detailed comments in the code regarding my reasoning for this behavior.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21560
diff changeset
357 jabber_auth_start_old(js);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
358 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
359 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
360 /* not reached */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
361 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
362
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
363 /* Fatal errors. Give up and go home */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
364 case SASL_BADPARAM:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
365 case SASL_NOMEM:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
366 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
367
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
368 /* For everything else, fail the mechanism and try again */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
369 default:
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
370 purple_debug_info("sasl", "sasl_state is %d, failing the mech and trying again\n", js->sasl_state);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
371
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
372 /*
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
373 * DAA: is this right?
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
374 * The manpage says that "mech" will contain the chosen mechanism on success.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
375 * Presumably, if we get here that isn't the case and we shouldn't try again?
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
376 * I suspect that this never happens.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
377 */
15765
51dd9ae01585 pass the correct domain to cyrus sasl (sf patch 1663064)
Nathan Walp <nwalp@pidgin.im>
parents: 15373
diff changeset
378 /*
51dd9ae01585 pass the correct domain to cyrus sasl (sf patch 1663064)
Nathan Walp <nwalp@pidgin.im>
parents: 15373
diff changeset
379 * SXW: Yes, this is right. What this handles is the situation where a
51dd9ae01585 pass the correct domain to cyrus sasl (sf patch 1663064)
Nathan Walp <nwalp@pidgin.im>
parents: 15373
diff changeset
380 * mechanism, say GSSAPI, is tried. If that mechanism fails, it may be
51dd9ae01585 pass the correct domain to cyrus sasl (sf patch 1663064)
Nathan Walp <nwalp@pidgin.im>
parents: 15373
diff changeset
381 * due to mechanism specific issues, so we want to try one of the other
51dd9ae01585 pass the correct domain to cyrus sasl (sf patch 1663064)
Nathan Walp <nwalp@pidgin.im>
parents: 15373
diff changeset
382 * supported mechanisms. This code handles that case
51dd9ae01585 pass the correct domain to cyrus sasl (sf patch 1663064)
Nathan Walp <nwalp@pidgin.im>
parents: 15373
diff changeset
383 */
28519
18b64ff28354 jabber: These uses of strlen() are unnecessary.
Paul Aurich <paul@darkrain42.org>
parents: 28518
diff changeset
384 if (js->current_mech && *js->current_mech) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
385 char *pos;
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
386 if ((pos = strstr(js->sasl_mechs->str, js->current_mech))) {
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
387 g_string_erase(js->sasl_mechs, pos-js->sasl_mechs->str, strlen(js->current_mech));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
388 }
22767
d5b3afea8764 After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evan.s@dreskin.net>
parents: 22672
diff changeset
389 /* Remove space which separated this mech from the next */
28519
18b64ff28354 jabber: These uses of strlen() are unnecessary.
Paul Aurich <paul@darkrain42.org>
parents: 28518
diff changeset
390 if ((js->sasl_mechs->str)[0] == ' ') {
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25358
diff changeset
391 g_string_erase(js->sasl_mechs, 0, 1);
22767
d5b3afea8764 After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evan.s@dreskin.net>
parents: 22672
diff changeset
392 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
393 again = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
394 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
395
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
396 sasl_dispose(&js->sasl);
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 } while (again);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
399
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
400 if (js->sasl_state == SASL_CONTINUE || js->sasl_state == SASL_OK) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
401 auth = xmlnode_new("auth");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
402 xmlnode_set_namespace(auth, "urn:ietf:params:xml:ns:xmpp-sasl");
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
403 xmlnode_set_attrib(auth, "mechanism", js->current_mech);
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25358
diff changeset
404
24565
915fdb649210 Send the "client-accepts-full-bind-result" attribute for Google Talk when
Paul Aurich <paul@darkrain42.org>
parents: 23389
diff changeset
405 xmlnode_set_attrib(auth, "xmlns:ga", "http://www.google.com/talk/protocol/auth");
915fdb649210 Send the "client-accepts-full-bind-result" attribute for Google Talk when
Paul Aurich <paul@darkrain42.org>
parents: 23389
diff changeset
406 xmlnode_set_attrib(auth, "ga:client-uses-full-bind-result", "true");
915fdb649210 Send the "client-accepts-full-bind-result" attribute for Google Talk when
Paul Aurich <paul@darkrain42.org>
parents: 23389
diff changeset
407
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
408 if (clientout) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
409 if (coutlen == 0) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
410 xmlnode_insert_data(auth, "=", -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
411 } else {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
412 enc_out = purple_base64_encode((unsigned char*)clientout, coutlen);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
413 xmlnode_insert_data(auth, enc_out, -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
414 g_free(enc_out);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
415 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
416 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
417 jabber_send(js, auth);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
418 xmlnode_free(auth);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
419 } else {
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
420 purple_connection_error_reason(js->gc,
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
421 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE,
27379
c4e5ba03ff73 Non localizable string?! Non!
Mark Doliner <mark@kingant.net>
parents: 27378
diff changeset
422 _("SASL authentication failed"));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
423 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
424 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
425
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
426 static int
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
427 jabber_sasl_cb_log(void *context, int level, const char *message)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
428 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
429 if(level <= SASL_LOG_TRACE)
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
430 purple_debug_info("sasl", "%s\n", message);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
431
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
432 return SASL_OK;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
433 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
434
16068
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
435 void
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
436 jabber_sasl_build_callbacks(JabberStream *js)
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
437 {
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
438 int id;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
439
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
440 /* Set up our callbacks structure */
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
441 if (js->sasl_cb == NULL)
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
442 js->sasl_cb = g_new0(sasl_callback_t,6);
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
443
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
444 id = 0;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
445 js->sasl_cb[id].id = SASL_CB_GETREALM;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
446 js->sasl_cb[id].proc = jabber_sasl_cb_realm;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
447 js->sasl_cb[id].context = (void *)js;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
448 id++;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
449
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
450 js->sasl_cb[id].id = SASL_CB_AUTHNAME;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
451 js->sasl_cb[id].proc = jabber_sasl_cb_simple;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
452 js->sasl_cb[id].context = (void *)js;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
453 id++;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
454
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
455 js->sasl_cb[id].id = SASL_CB_USER;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
456 js->sasl_cb[id].proc = jabber_sasl_cb_simple;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
457 js->sasl_cb[id].context = (void *)js;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
458 id++;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
459
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
460 if (purple_account_get_password(js->gc->account) != NULL ) {
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
461 js->sasl_cb[id].id = SASL_CB_PASS;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
462 js->sasl_cb[id].proc = jabber_sasl_cb_secret;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
463 js->sasl_cb[id].context = (void *)js;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
464 id++;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
465 }
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
466
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
467 js->sasl_cb[id].id = SASL_CB_LOG;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
468 js->sasl_cb[id].proc = jabber_sasl_cb_log;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
469 js->sasl_cb[id].context = (void*)js;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
470 id++;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
471
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
472 js->sasl_cb[id].id = SASL_CB_LIST_END;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
473 }
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
474
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
475 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
476
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
477 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
478 jabber_auth_start(JabberStream *js, xmlnode *packet)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
479 {
16068
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
480 #ifndef HAVE_CYRUS_SASL
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
481 gboolean digest_md5 = FALSE, plain=FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
482 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
483
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
484 xmlnode *mechs, *mechnode;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
485
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
486
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
487 if(js->registration) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
488 jabber_register_start(js);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
489 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
490 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
491
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
492 mechs = xmlnode_get_child(packet, "mechanisms");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
493
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
494 if(!mechs) {
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
495 purple_connection_error_reason(js->gc,
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
496 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
497 _("Invalid response from server"));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
498 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
499 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
500
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
501 #ifdef HAVE_CYRUS_SASL
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
502 js->sasl_mechs = g_string_new("");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
503 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
504
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
505 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
506 mechnode = xmlnode_get_next_twin(mechnode))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
507 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
508 char *mech_name = xmlnode_get_data(mechnode);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
509 #ifdef HAVE_CYRUS_SASL
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
510 /* Don't include Google Talk's X-GOOGLE-TOKEN mechanism, as we will not
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
511 * support it and including it gives a false fall-back to other mechs offerred,
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
512 * leading to incorrect error handling.
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
513 */
28514
5328e205d3fb jabber: Use purple_strequal to simplify some auth code
Paul Aurich <paul@darkrain42.org>
parents: 28513
diff changeset
514 if (purple_strequal(mech_name, "X-GOOGLE-TOKEN")) {
23080
0ae9c9befa63 Plug leak.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23075
diff changeset
515 g_free(mech_name);
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
516 continue;
23080
0ae9c9befa63 Plug leak.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23075
diff changeset
517 }
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
518
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
519 g_string_append(js->sasl_mechs, mech_name);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
520 g_string_append_c(js->sasl_mechs, ' ');
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
521 #else
28514
5328e205d3fb jabber: Use purple_strequal to simplify some auth code
Paul Aurich <paul@darkrain42.org>
parents: 28513
diff changeset
522 if (purple_strequal(mech_name, "DIGEST-MD5"))
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
523 digest_md5 = TRUE;
28514
5328e205d3fb jabber: Use purple_strequal to simplify some auth code
Paul Aurich <paul@darkrain42.org>
parents: 28513
diff changeset
524 else if (purple_strequal(mech_name, "PLAIN"))
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
525 plain = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
526 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
527 g_free(mech_name);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
528 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
529
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
530 #ifdef HAVE_CYRUS_SASL
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
531 js->auth_type = JABBER_AUTH_CYRUS;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
532
16068
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
533 jabber_sasl_build_callbacks(js);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
534
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
535 jabber_auth_start_cyrus(js);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
536 #else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
537
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
538 if(digest_md5) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
539 xmlnode *auth;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
540
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
541 js->auth_type = JABBER_AUTH_DIGEST_MD5;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
542 auth = xmlnode_new("auth");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
543 xmlnode_set_namespace(auth, "urn:ietf:params:xml:ns:xmpp-sasl");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
544 xmlnode_set_attrib(auth, "mechanism", "DIGEST-MD5");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
545
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
546 jabber_send(js, auth);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
547 xmlnode_free(auth);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
548 } else if(plain) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
549 js->auth_type = JABBER_AUTH_PLAIN;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
550
26272
fcee93c74230 BOSH: For authentication purposes, HTTPS is equivalent to a secured JabberStream.
Paul Aurich <paul@darkrain42.org>
parents: 25952
diff changeset
551 if(!jabber_stream_is_ssl(js) && !purple_account_get_bool(js->gc->account, "auth_plain_in_clear", FALSE)) {
16994
5f557e708335 fixes #763
Nathan Walp <nwalp@pidgin.im>
parents: 16651
diff changeset
552 char *msg = g_strdup_printf(_("%s requires plaintext authentication over an unencrypted connection. Allow this and continue authentication?"),
17012
b713af8ae274 I changed my mind, this should display the whole account name
Nathan Walp <nwalp@pidgin.im>
parents: 16994
diff changeset
553 js->gc->account->username);
21099
51cf02dbdb0e disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents: 21095
diff changeset
554 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
555 _("Plaintext Authentication"),
16994
5f557e708335 fixes #763
Nathan Walp <nwalp@pidgin.im>
parents: 16651
diff changeset
556 msg,
22143
70fc60344317 A few more of those "default_action" fixes
Mark Doliner <mark@kingant.net>
parents: 21949
diff changeset
557 1,
16439
08db93bbd798 Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents: 16316
diff changeset
558 purple_connection_get_account(js->gc), NULL, NULL,
21099
51cf02dbdb0e disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents: 21095
diff changeset
559 purple_connection_get_account(js->gc), allow_plaintext_auth,
51cf02dbdb0e disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents: 21095
diff changeset
560 disallow_plaintext_auth);
16994
5f557e708335 fixes #763
Nathan Walp <nwalp@pidgin.im>
parents: 16651
diff changeset
561 g_free(msg);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
562 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
563 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
564 finish_plaintext_authentication(js);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
565 } else {
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
566 purple_connection_error_reason(js->gc,
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
567 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
568 _("Server does not use any supported authentication method"));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
569 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
570 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
571 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
572
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
573 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
574 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
575 xmlnode *packet, gpointer data)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
576 {
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
577 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
578 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
579 jabber_disco_items_server(js);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
580 } else {
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
581 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
582 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
583 xmlnode *error;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
584 const char *err_code;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
585
20814
bde477ec6a71 Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <will.thompson@collabora.co.uk>
parents: 20792
diff changeset
586 /* 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
587 if((error = xmlnode_get_child(packet, "error")) &&
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
588 (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
589 g_str_equal(err_code, "401")) {
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
590 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
591 /* Clear the pasword if it isn't being saved */
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
592 if (!purple_account_get_remember_password(js->gc->account))
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
593 purple_account_set_password(js->gc->account, NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
594 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
595
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
596 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
597 g_free(msg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
598 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
599 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
600
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
601 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
602 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
603 xmlnode *packet, gpointer data)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
604 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
605 JabberIq *iq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
606 xmlnode *query, *x;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
607 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
608
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
609 if (type == JABBER_IQ_ERROR) {
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
610 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
611 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
612 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
613 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
614 } else if (type == JABBER_IQ_RESULT) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
615 query = xmlnode_get_child(packet, "query");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
616 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
617 char *s, *hash;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
618
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
619 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
620 query = xmlnode_get_child(iq->node, "query");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
621 x = xmlnode_new_child(query, "username");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
622 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
623 x = xmlnode_new_child(query, "resource");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
624 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
625
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
626 x = xmlnode_new_child(query, "digest");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
627 s = g_strdup_printf("%s%s", js->stream_id, pw);
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
628 hash = jabber_calculate_data_sha1sum(s, strlen(s));
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
629 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
630 g_free(hash);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
631 g_free(s);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
632 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
633 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
634
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
635 } 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
636 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
637 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
638 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
639
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
640 /* 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
641 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
642 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
643 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
644 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
645 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
646 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
647 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
648
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
649 /* 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
650 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
651 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
652
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
653 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
654 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
655 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
656 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
657
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
658 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
659
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
660 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
661
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
662 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
663 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
664
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
665 } else if(xmlnode_get_child(query, "password")) {
26272
fcee93c74230 BOSH: For authentication purposes, HTTPS is equivalent to a secured JabberStream.
Paul Aurich <paul@darkrain42.org>
parents: 25952
diff changeset
666 if(!jabber_stream_is_ssl(js) && !purple_account_get_bool(js->gc->account,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
667 "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
668 char *msg = g_strdup_printf(_("%s requires plaintext authentication over an unencrypted connection. Allow this and continue authentication?"),
fa7e07c74a59 The warning string for plaintext auth over an unencrypted connection is found
Evan Schoenberg <evan.s@dreskin.net>
parents: 22659
diff changeset
669 js->gc->account->username);
21099
51cf02dbdb0e disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents: 21095
diff changeset
670 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
671 _("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
672 msg,
22143
70fc60344317 A few more of those "default_action" fixes
Mark Doliner <mark@kingant.net>
parents: 21949
diff changeset
673 1,
16439
08db93bbd798 Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents: 16316
diff changeset
674 purple_connection_get_account(js->gc), NULL, NULL,
21099
51cf02dbdb0e disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents: 21095
diff changeset
675 purple_connection_get_account(js->gc), allow_plaintext_auth,
51cf02dbdb0e disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents: 21095
diff changeset
676 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
677 g_free(msg);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
678 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
679 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
680 finish_plaintext_authentication(js);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
681 } else {
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
682 purple_connection_error_reason(js->gc,
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
683 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE,
20117
f24a2cacacd1 Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <will.thompson@collabora.co.uk>
parents: 19999
diff changeset
684 _("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
685 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
686 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
687 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
688 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
689
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
690 void jabber_auth_start_old(JabberStream *js)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
691 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
692 JabberIq *iq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
693 xmlnode *query, *username;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
694
28292
fa77b70c8ca6 jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents: 28096
diff changeset
695 /*
fa77b70c8ca6 jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents: 28096
diff changeset
696 * 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
697 * <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
698 * 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
699 */
131e41a24d95 Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <paul@darkrain42.org>
parents: 26487
diff changeset
700 if (!jabber_stream_is_ssl(js) &&
28515
4fd0baa32a9e jabber: Fix a few places where the default for require_tls was wrong.
Paul Aurich <paul@darkrain42.org>
parents: 28514
diff changeset
701 purple_account_get_bool(purple_connection_get_account(js->gc), "require_tls", JABBER_DEFAULT_REQUIRE_TLS)) {
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
702 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
703 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
704 _("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
705 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
706 }
131e41a24d95 Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <paul@darkrain42.org>
parents: 26487
diff changeset
707
28292
fa77b70c8ca6 jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents: 28096
diff changeset
708 /*
fa77b70c8ca6 jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents: 28096
diff changeset
709 * 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
710 * 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
711 * 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
712 */
fa77b70c8ca6 jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents: 28096
diff changeset
713 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
714 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
715 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
716 }
fa77b70c8ca6 jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents: 28096
diff changeset
717
16068
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
718 #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
719 /* 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
720 * 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
721 * password prompting here
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
722 */
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
723
16068
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
724 if (!purple_account_get_password(js->gc->account)) {
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
725 purple_account_request_password(js->gc->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
726 return;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
727 }
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
728 #endif
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
729 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
730
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
731 query = xmlnode_get_child(iq->node, "query");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
732 username = xmlnode_new_child(query, "username");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
733 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
734
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
735 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
736
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
737 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
738 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
739
17183
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
740 /* Parts of this algorithm are inspired by stuff in libgsasl */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
741 static GHashTable* parse_challenge(const char *challenge)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
742 {
17183
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
743 const char *token_start, *val_start, *val_end, *cur;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
744 GHashTable *ret = g_hash_table_new_full(g_str_hash, g_str_equal,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
745 g_free, g_free);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
746
17183
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
747 cur = challenge;
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
748 while(*cur != '\0') {
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
749 /* Find the end of the token */
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
750 gboolean in_quotes = FALSE;
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
751 char *name, *value = NULL;
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
752 token_start = cur;
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
753 while(*cur != '\0' && (in_quotes || (!in_quotes && *cur != ','))) {
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
754 if (*cur == '"')
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
755 in_quotes = !in_quotes;
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
756 cur++;
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
757 }
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
758
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
759 /* Find start of value. */
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
760 val_start = strchr(token_start, '=');
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
761 if (val_start == NULL || val_start > cur)
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
762 val_start = cur;
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
763
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
764 if (token_start != val_start) {
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
765 name = g_strndup(token_start, val_start - token_start);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
766
17183
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
767 if (val_start != cur) {
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
768 val_start++;
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
769 while (val_start != cur && (*val_start == ' ' || *val_start == '\t'
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
770 || *val_start == '\r' || *val_start == '\n'
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
771 || *val_start == '"'))
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
772 val_start++;
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
773
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
774 val_end = cur;
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
775 while (val_end != val_start && (*val_end == ' ' || *val_end == ',' || *val_end == '\t'
25358
5529879da454 Two patches from Yann Kerherve submitted to pidgin-devl. This fixes XMPP
Evan Schoenberg <evan.s@dreskin.net>
parents: 24693
diff changeset
776 || *val_end == '\r' || *val_end == '\n'
5529879da454 Two patches from Yann Kerherve submitted to pidgin-devl. This fixes XMPP
Evan Schoenberg <evan.s@dreskin.net>
parents: 24693
diff changeset
777 || *val_end == '"' || *val_end == '\0'))
17183
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
778 val_end--;
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
779
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
780 if (val_start != val_end)
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
781 value = g_strndup(val_start, val_end - val_start + 1);
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
782 }
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
783
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
784 g_hash_table_replace(ret, name, value);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
785 }
17183
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
786
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
787 /* Find the start of the next token, if there is one */
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
788 if (*cur != '\0') {
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
789 cur++;
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
790 while (*cur == ' ' || *cur == ',' || *cur == '\t'
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
791 || *cur == '\r' || *cur == '\n')
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
792 cur++;
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
793 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
794 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
795
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
796 return ret;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
797 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
798
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
799 static char *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
800 generate_response_value(JabberID *jid, const char *passwd, const char *nonce,
27020
a0e3e4f37702 disapproval of revision '84a23ef59e6a3bc88834f0948c67516f0a39234b'
Paul Aurich <paul@darkrain42.org>
parents: 27015
diff changeset
801 const char *cnonce, const char *a2, const char *realm)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
802 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
803 PurpleCipher *cipher;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
804 PurpleCipherContext *context;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
805 guchar result[16];
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
806 size_t a1len;
27020
a0e3e4f37702 disapproval of revision '84a23ef59e6a3bc88834f0948c67516f0a39234b'
Paul Aurich <paul@darkrain42.org>
parents: 27015
diff changeset
807
27015
e696a0740a85 jabber digest-md5: Only specify the charset as UTF-8 if conversion to ISO-8859-1 was not successful.
Paul Aurich <paul@darkrain42.org>
parents: 26947
diff changeset
808 gchar *a1, *convnode=NULL, *convpasswd = NULL, *ha1, *ha2, *kd, *x, *z;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
809
19197
47942d19f301 Use -1 as length with g_convert() functions instead of strlen()
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18861
diff changeset
810 if((convnode = g_convert(jid->node, -1, "iso-8859-1", "utf-8",
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
811 NULL, NULL, NULL)) == NULL) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
812 convnode = g_strdup(jid->node);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
813 }
19197
47942d19f301 Use -1 as length with g_convert() functions instead of strlen()
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18861
diff changeset
814 if(passwd && ((convpasswd = g_convert(passwd, -1, "iso-8859-1",
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
815 "utf-8", NULL, NULL, NULL)) == NULL)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
816 convpasswd = g_strdup(passwd);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
817 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
818
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
819 cipher = purple_ciphers_find_cipher("md5");
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
820 context = purple_cipher_context_new(cipher, NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
821
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
822 x = g_strdup_printf("%s:%s:%s", convnode, realm, convpasswd ? convpasswd : "");
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
823 purple_cipher_context_append(context, (const guchar *)x, strlen(x));
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
824 purple_cipher_context_digest(context, sizeof(result), result, NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
825
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
826 a1 = g_strdup_printf("xxxxxxxxxxxxxxxx:%s:%s", nonce, cnonce);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
827 a1len = strlen(a1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
828 g_memmove(a1, result, 16);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
829
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
830 purple_cipher_context_reset(context, NULL);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
831 purple_cipher_context_append(context, (const guchar *)a1, a1len);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
832 purple_cipher_context_digest(context, sizeof(result), result, NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
833
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
834 ha1 = purple_base16_encode(result, 16);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
835
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
836 purple_cipher_context_reset(context, NULL);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
837 purple_cipher_context_append(context, (const guchar *)a2, strlen(a2));
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
838 purple_cipher_context_digest(context, sizeof(result), result, NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
839
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
840 ha2 = purple_base16_encode(result, 16);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
841
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
842 kd = g_strdup_printf("%s:%s:00000001:%s:auth:%s", ha1, nonce, cnonce, ha2);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
843
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
844 purple_cipher_context_reset(context, NULL);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
845 purple_cipher_context_append(context, (const guchar *)kd, strlen(kd));
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
846 purple_cipher_context_digest(context, sizeof(result), result, NULL);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
847 purple_cipher_context_destroy(context);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
848
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
849 z = purple_base16_encode(result, 16);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
850
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
851 g_free(convnode);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
852 g_free(convpasswd);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
853 g_free(x);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
854 g_free(a1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
855 g_free(ha1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
856 g_free(ha2);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
857 g_free(kd);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
858
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
859 return z;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
860 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
861
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
862 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
863 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
864 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
865
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
866 if(js->auth_type == JABBER_AUTH_DIGEST_MD5) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
867 char *enc_in = xmlnode_get_data(packet);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
868 char *dec_in;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
869 char *enc_out;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
870 GHashTable *parts;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
871
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
872 if(!enc_in) {
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
873 purple_connection_error_reason(js->gc,
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
874 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
875 _("Invalid response from server"));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
876 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
877 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
878
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
879 dec_in = (char *)purple_base64_decode(enc_in, NULL);
28513
fa7f3426ed13 jabber: Convert to purple_debug_* convenience functions.
Paul Aurich <paul@darkrain42.org>
parents: 28292
diff changeset
880 purple_debug_misc("jabber", "decoded challenge (%"
22486
3225c99785b8 Fix a bunch of compiler warnings caused by my addition of G_GNUC_PRINTF()
Mark Doliner <mark@kingant.net>
parents: 22207
diff changeset
881 G_GSIZE_FORMAT "): %s\n", strlen(dec_in), dec_in);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
882
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
883 parts = parse_challenge(dec_in);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
884
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
885
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
886 if (g_hash_table_lookup(parts, "rspauth")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
887 char *rspauth = g_hash_table_lookup(parts, "rspauth");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
888
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
889
28514
5328e205d3fb jabber: Use purple_strequal to simplify some auth code
Paul Aurich <paul@darkrain42.org>
parents: 28513
diff changeset
890 if (rspauth && purple_strequal(rspauth, js->expected_rspauth)) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
891 jabber_send_raw(js,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
892 "<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl' />",
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
893 -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
894 } else {
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
895 purple_connection_error_reason(js->gc,
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
896 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
20117
f24a2cacacd1 Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <will.thompson@collabora.co.uk>
parents: 19999
diff changeset
897 _("Invalid challenge from server"));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
898 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
899 g_free(js->expected_rspauth);
23098
c77d66886425 NULL out js->expected_rspauth, so it doesn't get double-freed in jabber_close().
Will Thompson <will.thompson@collabora.co.uk>
parents: 23080
diff changeset
900 js->expected_rspauth = NULL;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
901 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
902 /* assemble a response, and send it */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
903 /* see RFC 2831 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
904 char *realm;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
905 char *nonce;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
906
17183
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
907 /* Make sure the auth string contains everything that should be there.
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
908 This isn't everything in RFC2831, but it is what we need. */
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
909
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
910 nonce = g_hash_table_lookup(parts, "nonce");
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
911
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
912 /* we're actually supposed to prompt the user for a realm if
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
913 * the server doesn't send one, but that really complicates things,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
914 * so i'm not gonna worry about it until is poses a problem to
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
915 * someone, or I get really bored */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
916 realm = g_hash_table_lookup(parts, "realm");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
917 if(!realm)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
918 realm = js->user->domain;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
919
17183
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
920 if (nonce == NULL || realm == NULL)
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
921 purple_connection_error_reason(js->gc,
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
922 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
20117
f24a2cacacd1 Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <will.thompson@collabora.co.uk>
parents: 19999
diff changeset
923 _("Invalid challenge from server"));
17183
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
924 else {
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
925 GString *response = g_string_new("");
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
926 char *a2;
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
927 char *auth_resp;
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
928 char *buf;
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
929 char *cnonce;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
930
17183
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
931 cnonce = g_strdup_printf("%x%u%x", g_random_int(), (int)time(NULL),
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
932 g_random_int());
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
933
17183
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
934 a2 = g_strdup_printf("AUTHENTICATE:xmpp/%s", realm);
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
935 auth_resp = generate_response_value(js->user,
27020
a0e3e4f37702 disapproval of revision '84a23ef59e6a3bc88834f0948c67516f0a39234b'
Paul Aurich <paul@darkrain42.org>
parents: 27015
diff changeset
936 purple_connection_get_password(js->gc), nonce, cnonce, a2, realm);
17183
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
937 g_free(a2);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
938
17183
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
939 a2 = g_strdup_printf(":xmpp/%s", realm);
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
940 js->expected_rspauth = generate_response_value(js->user,
27020
a0e3e4f37702 disapproval of revision '84a23ef59e6a3bc88834f0948c67516f0a39234b'
Paul Aurich <paul@darkrain42.org>
parents: 27015
diff changeset
941 purple_connection_get_password(js->gc), nonce, cnonce, a2, realm);
17183
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
942 g_free(a2);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
943
17183
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
944 g_string_append_printf(response, "username=\"%s\"", js->user->node);
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
945 g_string_append_printf(response, ",realm=\"%s\"", realm);
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
946 g_string_append_printf(response, ",nonce=\"%s\"", nonce);
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
947 g_string_append_printf(response, ",cnonce=\"%s\"", cnonce);
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
948 g_string_append_printf(response, ",nc=00000001");
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
949 g_string_append_printf(response, ",qop=auth");
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
950 g_string_append_printf(response, ",digest-uri=\"xmpp/%s\"", realm);
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
951 g_string_append_printf(response, ",response=%s", auth_resp);
27020
a0e3e4f37702 disapproval of revision '84a23ef59e6a3bc88834f0948c67516f0a39234b'
Paul Aurich <paul@darkrain42.org>
parents: 27015
diff changeset
952 g_string_append_printf(response, ",charset=utf-8");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
953
17183
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
954 g_free(auth_resp);
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
955 g_free(cnonce);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
956
17183
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
957 enc_out = purple_base64_encode((guchar *)response->str, response->len);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
958
22486
3225c99785b8 Fix a bunch of compiler warnings caused by my addition of G_GNUC_PRINTF()
Mark Doliner <mark@kingant.net>
parents: 22207
diff changeset
959 purple_debug_misc("jabber", "decoded response (%"
3225c99785b8 Fix a bunch of compiler warnings caused by my addition of G_GNUC_PRINTF()
Mark Doliner <mark@kingant.net>
parents: 22207
diff changeset
960 G_GSIZE_FORMAT "): %s\n",
3225c99785b8 Fix a bunch of compiler warnings caused by my addition of G_GNUC_PRINTF()
Mark Doliner <mark@kingant.net>
parents: 22207
diff changeset
961 response->len, response->str);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
962
17183
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
963 buf = g_strdup_printf("<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>%s</response>", enc_out);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
964
17183
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
965 jabber_send_raw(js, buf, -1);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
966
17183
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
967 g_free(buf);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
968
17183
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
969 g_free(enc_out);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
970
17183
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
971 g_string_free(response, TRUE);
61c5d8737f01 Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17012
diff changeset
972 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
973 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
974
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
975 g_free(enc_in);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
976 g_free(dec_in);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
977 g_hash_table_destroy(parts);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
978 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
979 #ifdef HAVE_CYRUS_SASL
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
980 else if (js->auth_type == JABBER_AUTH_CYRUS) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
981 char *enc_in = xmlnode_get_data(packet);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
982 unsigned char *dec_in;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
983 char *enc_out;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
984 const char *c_out;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
985 unsigned int clen;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
986 gsize declen;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
987 xmlnode *response;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
988
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
989 dec_in = purple_base64_decode(enc_in, &declen);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
990
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
991 js->sasl_state = sasl_client_step(js->sasl, (char*)dec_in, declen,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
992 NULL, &c_out, &clen);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
993 g_free(enc_in);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
994 g_free(dec_in);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
995 if (js->sasl_state != SASL_CONTINUE && js->sasl_state != SASL_OK) {
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
996 gchar *tmp = g_strdup_printf(_("SASL error: %s"),
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
997 sasl_errdetail(js->sasl));
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
998 purple_debug_error("jabber", "Error is %d : %s\n",
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
999 js->sasl_state, sasl_errdetail(js->sasl));
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
1000 purple_connection_error_reason(js->gc,
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
1001 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
1002 g_free(tmp);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1003 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1004 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1005 response = xmlnode_new("response");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1006 xmlnode_set_namespace(response, "urn:ietf:params:xml:ns:xmpp-sasl");
16651
a6854e3043a4 Don't try to base64 encode and then append an empty string
Mark Doliner <mark@kingant.net>
parents: 16496
diff changeset
1007 if (clen > 0) {
27039
9a79f8a99259 Set charset=utf-8 when cyrus sasl doesn't include it.
Paul Aurich <paul@darkrain42.org>
parents: 27020
diff changeset
1008 /* Cyrus SASL 2.1.22 appears to contain code to add the charset
27151
4ea129edc62c Only append ,charset=utf-8 for DIGEST-MD5. This should fix comment 2 on Adium#12429.
Paul Aurich <paul@darkrain42.org>
parents: 27042
diff changeset
1009 * to the response for DIGEST-MD5 but there is no possibility
4ea129edc62c Only append ,charset=utf-8 for DIGEST-MD5. This should fix comment 2 on Adium#12429.
Paul Aurich <paul@darkrain42.org>
parents: 27042
diff changeset
1010 * it will be executed.
4ea129edc62c Only append ,charset=utf-8 for DIGEST-MD5. This should fix comment 2 on Adium#12429.
Paul Aurich <paul@darkrain42.org>
parents: 27042
diff changeset
1011 *
27039
9a79f8a99259 Set charset=utf-8 when cyrus sasl doesn't include it.
Paul Aurich <paul@darkrain42.org>
parents: 27020
diff changeset
1012 * My reading of the digestmd5 plugin indicates the username and
9a79f8a99259 Set charset=utf-8 when cyrus sasl doesn't include it.
Paul Aurich <paul@darkrain42.org>
parents: 27020
diff changeset
1013 * realm are always encoded in UTF-8 (they seem to be the values
9a79f8a99259 Set charset=utf-8 when cyrus sasl doesn't include it.
Paul Aurich <paul@darkrain42.org>
parents: 27020
diff changeset
1014 * we pass in), so we need to ensure charset=utf-8 is set.
9a79f8a99259 Set charset=utf-8 when cyrus sasl doesn't include it.
Paul Aurich <paul@darkrain42.org>
parents: 27020
diff changeset
1015 */
28514
5328e205d3fb jabber: Use purple_strequal to simplify some auth code
Paul Aurich <paul@darkrain42.org>
parents: 28513
diff changeset
1016 if (!purple_strequal(js->current_mech, "DIGEST-MD5") ||
27151
4ea129edc62c Only append ,charset=utf-8 for DIGEST-MD5. This should fix comment 2 on Adium#12429.
Paul Aurich <paul@darkrain42.org>
parents: 27042
diff changeset
1017 strstr(c_out, ",charset="))
4ea129edc62c Only append ,charset=utf-8 for DIGEST-MD5. This should fix comment 2 on Adium#12429.
Paul Aurich <paul@darkrain42.org>
parents: 27042
diff changeset
1018 /* If we're not using DIGEST-MD5 or Cyrus SASL is fixed */
27039
9a79f8a99259 Set charset=utf-8 when cyrus sasl doesn't include it.
Paul Aurich <paul@darkrain42.org>
parents: 27020
diff changeset
1019 enc_out = purple_base64_encode((unsigned char*)c_out, clen);
9a79f8a99259 Set charset=utf-8 when cyrus sasl doesn't include it.
Paul Aurich <paul@darkrain42.org>
parents: 27020
diff changeset
1020 else {
9a79f8a99259 Set charset=utf-8 when cyrus sasl doesn't include it.
Paul Aurich <paul@darkrain42.org>
parents: 27020
diff changeset
1021 char *tmp = g_strdup_printf("%s,charset=utf-8", c_out);
27042
Paul Aurich <paul@darkrain42.org>
parents: 27039
diff changeset
1022 enc_out = purple_base64_encode((unsigned char*)tmp, clen + 14);
27039
9a79f8a99259 Set charset=utf-8 when cyrus sasl doesn't include it.
Paul Aurich <paul@darkrain42.org>
parents: 27020
diff changeset
1023 g_free(tmp);
9a79f8a99259 Set charset=utf-8 when cyrus sasl doesn't include it.
Paul Aurich <paul@darkrain42.org>
parents: 27020
diff changeset
1024 }
9a79f8a99259 Set charset=utf-8 when cyrus sasl doesn't include it.
Paul Aurich <paul@darkrain42.org>
parents: 27020
diff changeset
1025
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1026 xmlnode_insert_data(response, enc_out, -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1027 g_free(enc_out);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1028 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1029 jabber_send(js, response);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1030 xmlnode_free(response);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1031 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1032 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1033 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1034 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1035
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1036 void jabber_auth_handle_success(JabberStream *js, xmlnode *packet)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1037 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1038 const char *ns = xmlnode_get_namespace(packet);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1039 #ifdef HAVE_CYRUS_SASL
16316
c1f2831c1afe Get rid of two really minor warnings
Mark Doliner <mark@kingant.net>
parents: 16068
diff changeset
1040 const void *x;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1041 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1042
28514
5328e205d3fb jabber: Use purple_strequal to simplify some auth code
Paul Aurich <paul@darkrain42.org>
parents: 28513
diff changeset
1043 if (!purple_strequal(ns, "urn:ietf:params:xml:ns:xmpp-sasl")) {
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
1044 purple_connection_error_reason(js->gc,
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
1045 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
1046 _("Invalid response from server"));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1047 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1048 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1049
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1050 #ifdef HAVE_CYRUS_SASL
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1051 /* The SASL docs say that if the client hasn't returned OK yet, we
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1052 * should try one more round against it
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1053 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1054 if (js->sasl_state != SASL_OK) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1055 char *enc_in = xmlnode_get_data(packet);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1056 unsigned char *dec_in = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1057 const char *c_out;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1058 unsigned int clen;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1059 gsize declen = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1060
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1061 if(enc_in != NULL)
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
1062 dec_in = purple_base64_decode(enc_in, &declen);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1063
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1064 js->sasl_state = sasl_client_step(js->sasl, (char*)dec_in, declen, NULL, &c_out, &clen);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1065
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1066 g_free(enc_in);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1067 g_free(dec_in);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1068
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1069 if (js->sasl_state != SASL_OK) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1070 /* This should never happen! */
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
1071 purple_connection_error_reason(js->gc,
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
1072 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
1073 _("Invalid response from server"));
28520
682b441d4944 Hmm, I think I'm reaching diminishing returns.
Paul Aurich <paul@darkrain42.org>
parents: 28519
diff changeset
1074 g_return_if_reached();
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1075 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1076 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1077 /* If we've negotiated a security layer, we need to enable it */
21949
18628d7aba30 Ensure js->sasl is not NULL before using it in jabber_auth_handle_success(). This was, I believe, the source of the crash stu reported when my DIGEST-MD5 hack was in place; while js->sasl will probably be non-NULL whenever we reach this code point now, it's more robust to verify it here since that's an assumption originating in another function.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21923
diff changeset
1078 if (js->sasl) {
18628d7aba30 Ensure js->sasl is not NULL before using it in jabber_auth_handle_success(). This was, I believe, the source of the crash stu reported when my DIGEST-MD5 hack was in place; while js->sasl will probably be non-NULL whenever we reach this code point now, it's more robust to verify it here since that's an assumption originating in another function.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21923
diff changeset
1079 sasl_getprop(js->sasl, SASL_SSF, &x);
18628d7aba30 Ensure js->sasl is not NULL before using it in jabber_auth_handle_success(). This was, I believe, the source of the crash stu reported when my DIGEST-MD5 hack was in place; while js->sasl will probably be non-NULL whenever we reach this code point now, it's more robust to verify it here since that's an assumption originating in another function.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21923
diff changeset
1080 if (*(int *)x > 0) {
18628d7aba30 Ensure js->sasl is not NULL before using it in jabber_auth_handle_success(). This was, I believe, the source of the crash stu reported when my DIGEST-MD5 hack was in place; while js->sasl will probably be non-NULL whenever we reach this code point now, it's more robust to verify it here since that's an assumption originating in another function.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21923
diff changeset
1081 sasl_getprop(js->sasl, SASL_MAXOUTBUF, &x);
18628d7aba30 Ensure js->sasl is not NULL before using it in jabber_auth_handle_success(). This was, I believe, the source of the crash stu reported when my DIGEST-MD5 hack was in place; while js->sasl will probably be non-NULL whenever we reach this code point now, it's more robust to verify it here since that's an assumption originating in another function.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21923
diff changeset
1082 js->sasl_maxbuf = *(int *)x;
18628d7aba30 Ensure js->sasl is not NULL before using it in jabber_auth_handle_success(). This was, I believe, the source of the crash stu reported when my DIGEST-MD5 hack was in place; while js->sasl will probably be non-NULL whenever we reach this code point now, it's more robust to verify it here since that's an assumption originating in another function.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21923
diff changeset
1083 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1084 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1085 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1086
28096
b357216b7b79 jabber: Fix using BOSH and legacy auth together. Closes #9990.
Paul Aurich <paul@darkrain42.org>
parents: 28048
diff changeset
1087 /*
b357216b7b79 jabber: Fix using BOSH and legacy auth together. Closes #9990.
Paul Aurich <paul@darkrain42.org>
parents: 28048
diff changeset
1088 * 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
1089 * jabber_bosh_connection_send.
b357216b7b79 jabber: Fix using BOSH and legacy auth together. Closes #9990.
Paul Aurich <paul@darkrain42.org>
parents: 28048
diff changeset
1090 */
b357216b7b79 jabber: Fix using BOSH and legacy auth together. Closes #9990.
Paul Aurich <paul@darkrain42.org>
parents: 28048
diff changeset
1091 js->reinit = TRUE;
b357216b7b79 jabber: Fix using BOSH and legacy auth together. Closes #9990.
Paul Aurich <paul@darkrain42.org>
parents: 28048
diff changeset
1092 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
1093 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1094
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1095 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
1096 {
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
1097 PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR;
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
1098 char *msg;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1099
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
1100 #ifdef HAVE_CYRUS_SASL
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
1101 if(js->auth_fail_count++ < 5) {
28519
18b64ff28354 jabber: These uses of strlen() are unnecessary.
Paul Aurich <paul@darkrain42.org>
parents: 28518
diff changeset
1102 if (js->current_mech && *js->current_mech) {
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
1103 char *pos;
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
1104 if ((pos = strstr(js->sasl_mechs->str, js->current_mech))) {
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
1105 g_string_erase(js->sasl_mechs, pos-js->sasl_mechs->str, strlen(js->current_mech));
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
1106 }
22767
d5b3afea8764 After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evan.s@dreskin.net>
parents: 22672
diff changeset
1107 /* Remove space which separated this mech from the next */
28519
18b64ff28354 jabber: These uses of strlen() are unnecessary.
Paul Aurich <paul@darkrain42.org>
parents: 28518
diff changeset
1108 if ((js->sasl_mechs->str)[0] == ' ') {
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25358
diff changeset
1109 g_string_erase(js->sasl_mechs, 0, 1);
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25358
diff changeset
1110 }
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
1111 }
28519
18b64ff28354 jabber: These uses of strlen() are unnecessary.
Paul Aurich <paul@darkrain42.org>
parents: 28518
diff changeset
1112 if (*js->sasl_mechs->str) {
22767
d5b3afea8764 After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evan.s@dreskin.net>
parents: 22672
diff changeset
1113 /* If we have remaining mechs to try, do so */
d5b3afea8764 After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evan.s@dreskin.net>
parents: 22672
diff changeset
1114 sasl_dispose(&js->sasl);
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25358
diff changeset
1115
22767
d5b3afea8764 After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evan.s@dreskin.net>
parents: 22672
diff changeset
1116 jabber_auth_start_cyrus(js);
d5b3afea8764 After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evan.s@dreskin.net>
parents: 22672
diff changeset
1117 return;
d5b3afea8764 After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evan.s@dreskin.net>
parents: 22672
diff changeset
1118 }
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
1119 }
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
1120 #endif
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
1121 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
1122 if(!msg) {
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
1123 purple_connection_error_reason(js->gc,
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
1124 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
1125 _("Invalid response from server"));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1126 } else {
27381
f541583e31bd More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents: 27379
diff changeset
1127 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
1128 g_free(msg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1129 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1130 }