annotate libpurple/protocols/jabber/auth.c @ 23072:fb87b6d77543

A (modified) patch from Felipe to simplify our GStreamer sink selection code. There's no need to initialize autoaudiosink ourselves, as playbin will do that for us if we pass NULL. Fixes #5770 committer: Richard Laager <rlaager@wiktel.com>
author Felipe Contreras <felipe.contreras@gmail.com>
date Wed, 21 May 2008 22:06:52 +0000
parents 42dfa1139b5c
children ab9c48e85577 9d331ad0a8dc
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 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
4 * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6 * 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
7 * 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
8 * 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
9 * (at your option) any later version.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * 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
12 * 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
13 * 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
14 * GNU General Public License for more details.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * 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
17 * 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
18 * 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
19 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 #include "internal.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22
15889
87ea711b9781 Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <stu@nosnilmot.com>
parents: 15822
diff changeset
23 #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
24 #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
25 #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
26 #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
27 #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
28 #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
29 #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
30 #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
31 #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
32
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 #include "jutil.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 #include "auth.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 #include "jabber.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 #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
37 #include "notify.h"
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39 static void auth_old_result_cb(JabberStream *js, xmlnode *packet,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40 gpointer data);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 gboolean
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43 jabber_process_starttls(JabberStream *js, xmlnode *packet)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45 xmlnode *starttls;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47 if((starttls = xmlnode_get_child(packet, "starttls"))) {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
48 if(purple_ssl_is_supported()) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 jabber_send_raw(js,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 "<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
51 return TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52 } else if(xmlnode_get_child(starttls, "required")) {
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
53 purple_connection_error_reason (js->gc,
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
54 PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT,
20117
f24a2cacacd1 Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <will.thompson@collabora.co.uk>
parents: 19999
diff changeset
55 _("Server requires TLS/SSL for login. No TLS/SSL support found."));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 return TRUE;
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
57 } else if(purple_account_get_bool(js->gc->account, "require_tls", FALSE)) {
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
58 purple_connection_error_reason (js->gc,
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
59 PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT,
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
60 _("You require encryption, but no TLS/SSL support found."));
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
61 return TRUE;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
63 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65 return FALSE;
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 static void finish_plaintext_authentication(JabberStream *js)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70 if(js->auth_type == JABBER_AUTH_PLAIN) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71 xmlnode *auth;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72 GString *response;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73 gchar *enc_out;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
74
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75 auth = xmlnode_new("auth");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76 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
77
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78 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
79 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
80
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81 response = g_string_new("");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82 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
83 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
84 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
85 response = g_string_append(response,
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
86 purple_connection_get_password(js->gc));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
88 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
89
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
90 xmlnode_set_attrib(auth, "mechanism", "PLAIN");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
91 xmlnode_insert_data(auth, enc_out, -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
92 g_free(enc_out);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
93 g_string_free(response, TRUE);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95 jabber_send(js, auth);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
96 xmlnode_free(auth);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97 } 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
98 JabberIq *iq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99 xmlnode *query, *x;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
100
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
101 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
102 query = xmlnode_get_child(iq->node, "query");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
103 x = xmlnode_new_child(query, "username");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
104 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
105 x = xmlnode_new_child(query, "resource");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
106 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
107 x = xmlnode_new_child(query, "password");
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
108 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
109 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
110 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
111 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
112 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
114 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
115 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
116 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
117
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118 finish_plaintext_authentication(account->gc->proto_data);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
121 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
122 {
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
123 purple_connection_error_reason (account->gc,
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
124 PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR,
20117
f24a2cacacd1 Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <will.thompson@collabora.co.uk>
parents: 19999
diff changeset
125 _("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
126 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
127
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128 #ifdef HAVE_CYRUS_SASL
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
130 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
131 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
132
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133 /* Callbacks for Cyrus SASL */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135 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
136 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 JabberStream *js = (JabberStream *)ctx;
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 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
140
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
141 *result = js->user->domain;
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 return SASL_OK;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
144 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146 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
147 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
148 JabberStream *js = (JabberStream *)ctx;
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 switch(id) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
151 case SASL_CB_AUTHNAME:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
152 *res = js->user->node;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
153 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
154 case SASL_CB_USER:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
155 *res = "";
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
156 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
157 default:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158 return SASL_BADPARAM;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160 if (len) *len = strlen((char *)*res);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
161 return SASL_OK;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
162 }
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 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
165 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
166 JabberStream *js = (JabberStream *)ctx;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
167 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
168 size_t len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169 static sasl_secret_t *x = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
171 if (!conn || !secret || id != SASL_CB_PASS)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
172 return SASL_BADPARAM;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
173
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
174 len = strlen(pw);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
175 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
176
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177 if (!x)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
178 return SASL_NOMEM;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180 x->len = len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181 strcpy((char*)x->data, pw);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
183 *secret = x;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184 return SASL_OK;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
186
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
187 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
188 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
189 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
190
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
191 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
192 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
193
16068
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
194 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
195 {
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
196 const char *entry;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
197 gboolean remember;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
198
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
199 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
200 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
201
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
202 if (!entry || !*entry)
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
203 {
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
204 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
205 return FALSE;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
206 }
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 if (remember)
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
209 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
210
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
211 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
212
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
213 return TRUE;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
214 }
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
215
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
216 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
217 {
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
218 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
219
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 /* 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
221 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
222 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
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 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
225
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
226 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
227 return;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
228
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
229 /* 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
230 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
231
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
232 /* Restart our connection */
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
233 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
234 }
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 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
237 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
238 {
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
239 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
240
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 /* 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
242 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
243 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
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 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
246
16068
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
247 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
248 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
249
16068
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
250 /* Restart our connection */
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
251 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
252 }
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
253
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
254
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
255 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
256 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
257 {
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
258 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
259
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 /* 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
261 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
262 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
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 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
265
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
266 /* 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
267 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
268 }
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
269
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
270 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
271 {
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
272 const char *clientout = NULL;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
273 char *enc_out;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
274 unsigned coutlen = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
275 xmlnode *auth;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
276 sasl_security_properties_t secprops;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
277 gboolean again;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
278 gboolean plaintext = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
279
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
280 /* Set up security properties and options */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
281 secprops.min_ssf = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
282 secprops.security_flags = SASL_SEC_NOANONYMOUS;
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 if (!js->gsc) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
285 secprops.max_ssf = -1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
286 secprops.maxbufsize = 4096;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
287 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
288 if (!plaintext)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
289 secprops.security_flags |= SASL_SEC_NOPLAINTEXT;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
290 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
291 secprops.max_ssf = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
292 secprops.maxbufsize = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
293 plaintext = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
294 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
295 secprops.property_names = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
296 secprops.property_values = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
297
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
298 do {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
299 again = FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
300
15765
51dd9ae01585 pass the correct domain to cyrus sasl (sf patch 1663064)
Nathan Walp <nwalp@pidgin.im>
parents: 15373
diff changeset
301 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
302 if (js->sasl_state==SASL_OK) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
303 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
304 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
305 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
306 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
307 switch (js->sasl_state) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
308 /* Success */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
309 case SASL_OK:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
310 case SASL_CONTINUE:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
311 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
312 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
313 /* 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
314
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
315 /* 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
316 * to get one
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
317 */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
318
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
319 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
320 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
321 return;
16068
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
322
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
323 /* 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
324 * 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
325 * plaintext auth
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
326 */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
327 } else if (!plaintext) {
16994
5f557e708335 fixes #763
Nathan Walp <nwalp@pidgin.im>
parents: 16651
diff changeset
328 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
329 js->gc->account->username);
21099
51cf02dbdb0e disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents: 21095
diff changeset
330 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
331 _("Plaintext Authentication"),
16994
5f557e708335 fixes #763
Nathan Walp <nwalp@pidgin.im>
parents: 16651
diff changeset
332 msg,
22143
70fc60344317 A few more of those "default_action" fixes
Mark Doliner <mark@kingant.net>
parents: 21949
diff changeset
333 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
334 allow_cyrus_plaintext_auth,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
335 disallow_plaintext_auth);
16994
5f557e708335 fixes #763
Nathan Walp <nwalp@pidgin.im>
parents: 16651
diff changeset
336 g_free(msg);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
337 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
338
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
339 } 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
340 /* 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
341 * 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
342 * 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
343 * 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
344 * 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
345 * 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
346 *
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 * 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
348 * 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
349 * 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
350 * 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
351 */
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
352 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
353 jabber_auth_start_old(js);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
354 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
355 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
356 /* not reached */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
357 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
358
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
359 /* Fatal errors. Give up and go home */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
360 case SASL_BADPARAM:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
361 case SASL_NOMEM:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
362 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
363
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
364 /* 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
365 default:
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
366 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
367
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
368 /*
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
369 * DAA: is this right?
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
370 * 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
371 * 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
372 * I suspect that this never happens.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
373 */
15765
51dd9ae01585 pass the correct domain to cyrus sasl (sf patch 1663064)
Nathan Walp <nwalp@pidgin.im>
parents: 15373
diff changeset
374 /*
51dd9ae01585 pass the correct domain to cyrus sasl (sf patch 1663064)
Nathan Walp <nwalp@pidgin.im>
parents: 15373
diff changeset
375 * 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
376 * 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
377 * 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
378 * 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
379 */
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
380 if (js->current_mech && strlen(js->current_mech) > 0) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
381 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
382 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
383 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
384 }
22767
d5b3afea8764 After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evan.s@dreskin.net>
parents: 22672
diff changeset
385 /* Remove space which separated this mech from the next */
d5b3afea8764 After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evan.s@dreskin.net>
parents: 22672
diff changeset
386 if (strlen(js->sasl_mechs->str) > 0 && ((js->sasl_mechs->str)[0] == ' ')) {
d5b3afea8764 After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evan.s@dreskin.net>
parents: 22672
diff changeset
387 g_string_erase(js->sasl_mechs, 0, 1);
d5b3afea8764 After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evan.s@dreskin.net>
parents: 22672
diff changeset
388 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
389 again = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
390 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
391
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
392 sasl_dispose(&js->sasl);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
393 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
394 } while (again);
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 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
397 auth = xmlnode_new("auth");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
398 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
399 xmlnode_set_attrib(auth, "mechanism", js->current_mech);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
400 if (clientout) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
401 if (coutlen == 0) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
402 xmlnode_insert_data(auth, "=", -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
403 } else {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
404 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
405 xmlnode_insert_data(auth, enc_out, -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
406 g_free(enc_out);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
407 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
408 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
409 jabber_send(js, auth);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
410 xmlnode_free(auth);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
411 } else {
20117
f24a2cacacd1 Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <will.thompson@collabora.co.uk>
parents: 19999
diff changeset
412 purple_connection_error_reason (js->gc,
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
413 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE,
20117
f24a2cacacd1 Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <will.thompson@collabora.co.uk>
parents: 19999
diff changeset
414 "SASL authentication failed\n");
15373
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
418 static int
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
419 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
420 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
421 if(level <= SASL_LOG_TRACE)
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
422 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
423
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
424 return SASL_OK;
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
16068
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
427 void
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
428 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
429 {
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
430 int id;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
431
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
432 /* 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
433 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
434 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
435
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
436 id = 0;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
437 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
438 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
439 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
440 id++;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
441
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[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
443 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
444 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
445 id++;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
446
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].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
448 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
449 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
450 id++;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
451
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
452 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
453 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
454 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
455 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
456 id++;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
457 }
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
458
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
459 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
460 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
461 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
462 id++;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
463
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
464 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
465 }
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
466
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
467 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
468
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
469 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
470 jabber_auth_start(JabberStream *js, xmlnode *packet)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
471 {
16068
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
472 #ifndef HAVE_CYRUS_SASL
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
473 gboolean digest_md5 = FALSE, plain=FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
474 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
475
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
476 xmlnode *mechs, *mechnode;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
477
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
478
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
479 if(js->registration) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
480 jabber_register_start(js);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
481 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
482 }
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 mechs = xmlnode_get_child(packet, "mechanisms");
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 if(!mechs) {
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
487 purple_connection_error_reason (js->gc,
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
488 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
20117
f24a2cacacd1 Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <will.thompson@collabora.co.uk>
parents: 19999
diff changeset
489 _("Invalid response from server."));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
490 return;
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
493 #ifdef HAVE_CYRUS_SASL
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
494 js->sasl_mechs = g_string_new("");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
495 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
496
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
497 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
498 mechnode = xmlnode_get_next_twin(mechnode))
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 char *mech_name = xmlnode_get_data(mechnode);
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 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
503 g_string_append_c(js->sasl_mechs, ' ');
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
504 #else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
505 if(mech_name && !strcmp(mech_name, "DIGEST-MD5"))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
506 digest_md5 = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
507 else if(mech_name && !strcmp(mech_name, "PLAIN"))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
508 plain = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
509 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
510 g_free(mech_name);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
511 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
512
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
513 #ifdef HAVE_CYRUS_SASL
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
514 js->auth_type = JABBER_AUTH_CYRUS;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
515
16068
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
516 jabber_sasl_build_callbacks(js);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
517
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
518 jabber_auth_start_cyrus(js);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
519 #else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
520
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
521 if(digest_md5) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
522 xmlnode *auth;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
523
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
524 js->auth_type = JABBER_AUTH_DIGEST_MD5;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
525 auth = xmlnode_new("auth");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
526 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
527 xmlnode_set_attrib(auth, "mechanism", "DIGEST-MD5");
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 jabber_send(js, auth);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
530 xmlnode_free(auth);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
531 } else if(plain) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
532 js->auth_type = JABBER_AUTH_PLAIN;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
533
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
534 if(js->gsc == NULL && !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
535 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
536 js->gc->account->username);
21099
51cf02dbdb0e disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents: 21095
diff changeset
537 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
538 _("Plaintext Authentication"),
16994
5f557e708335 fixes #763
Nathan Walp <nwalp@pidgin.im>
parents: 16651
diff changeset
539 msg,
22143
70fc60344317 A few more of those "default_action" fixes
Mark Doliner <mark@kingant.net>
parents: 21949
diff changeset
540 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
541 purple_connection_get_account(js->gc), NULL, NULL,
21099
51cf02dbdb0e disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents: 21095
diff changeset
542 purple_connection_get_account(js->gc), allow_plaintext_auth,
51cf02dbdb0e disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents: 21095
diff changeset
543 disallow_plaintext_auth);
16994
5f557e708335 fixes #763
Nathan Walp <nwalp@pidgin.im>
parents: 16651
diff changeset
544 g_free(msg);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
545 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
546 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
547 finish_plaintext_authentication(js);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
548 } else {
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
549 purple_connection_error_reason (js->gc,
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
550 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
551 _("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
552 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
553 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
554 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
555
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
556 static void auth_old_result_cb(JabberStream *js, xmlnode *packet, gpointer data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
557 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
558 const char *type = xmlnode_get_attrib(packet, "type");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
559
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
560 if(type && !strcmp(type, "result")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
561 jabber_stream_set_state(js, JABBER_STREAM_CONNECTED);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
562 } else {
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
563 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
564 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
565 xmlnode *error;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
566 const char *err_code;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
567
20814
bde477ec6a71 Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <will.thompson@collabora.co.uk>
parents: 20792
diff changeset
568 /* 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
569 if((error = xmlnode_get_child(packet, "error")) &&
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
570 (err_code = xmlnode_get_attrib(error, "code")) &&
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
571 !strcmp(err_code, "401")) {
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
572 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
573 /* 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
574 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
575 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
576 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
577
20778
8174f6999308 Sprinkle gc->wants_to_die = TRUE liberally around connection errors that really
Will Thompson <will.thompson@collabora.co.uk>
parents: 20776
diff changeset
578 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
579 g_free(msg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
580 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
581 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
582
21854
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
583 /*!
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
584 * @brief Given the server challenge (message) and the key (password), calculate the HMAC-MD5 digest
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
585 *
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
586 * This is the crammd5 response. Inspired by cyrus-sasl's _sasl_hmac_md5()
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
587 */
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
588 static void
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
589 auth_hmac_md5(const char *challenge, size_t challenge_len, const char *key, size_t key_len, guchar *digest)
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
590 {
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
591 PurpleCipher *cipher;
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
592 PurpleCipherContext *context;
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
593 int i;
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
594 /* inner padding - key XORd with ipad */
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
595 unsigned char k_ipad[65];
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
596 /* outer padding - key XORd with opad */
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
597 unsigned char k_opad[65];
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
598
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
599 cipher = purple_ciphers_find_cipher("md5");
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
600
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
601 /* if key is longer than 64 bytes reset it to key=MD5(key) */
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
602 if (strlen(key) > 64) {
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
603 guchar keydigest[16];
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
604
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
605 context = purple_cipher_context_new(cipher, NULL);
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
606 purple_cipher_context_append(context, (const guchar *)key, strlen(key));
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
607 purple_cipher_context_digest(context, 16, keydigest, NULL);
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
608 purple_cipher_context_destroy(context);
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
609
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
610 key = (char *)keydigest;
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
611 key_len = 16;
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
612 }
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
613
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
614 /*
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
615 * the HMAC_MD5 transform looks like:
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
616 *
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
617 * MD5(K XOR opad, MD5(K XOR ipad, text))
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
618 *
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
619 * where K is an n byte key
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
620 * ipad is the byte 0x36 repeated 64 times
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
621 * opad is the byte 0x5c repeated 64 times
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
622 * and text is the data being protected
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
623 */
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
624
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
625 /* start out by storing key in pads */
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
626 memset(k_ipad, '\0', sizeof k_ipad);
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
627 memset(k_opad, '\0', sizeof k_opad);
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
628 memcpy(k_ipad, (void *)key, key_len);
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
629 memcpy(k_opad, (void *)key, key_len);
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
630
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
631 /* XOR key with ipad and opad values */
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
632 for (i=0; i<64; i++) {
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
633 k_ipad[i] ^= 0x36;
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
634 k_opad[i] ^= 0x5c;
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
635 }
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
636
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
637 /* perform inner MD5 */
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
638 context = purple_cipher_context_new(cipher, NULL);
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
639 purple_cipher_context_append(context, k_ipad, 64); /* start with inner pad */
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
640 purple_cipher_context_append(context, (const guchar *)challenge, challenge_len); /* then text of datagram */
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
641 purple_cipher_context_digest(context, 16, digest, NULL); /* finish up 1st pass */
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
642 purple_cipher_context_destroy(context);
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
643
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
644 /* perform outer MD5 */
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
645 context = purple_cipher_context_new(cipher, NULL);
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
646 purple_cipher_context_append(context, k_opad, 64); /* start with outer pad */
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
647 purple_cipher_context_append(context, digest, 16); /* then results of 1st hash */
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
648 purple_cipher_context_digest(context, 16, digest, NULL); /* finish up 2nd pass */
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
649 purple_cipher_context_destroy(context);
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
650 }
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
651
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
652 static void auth_old_cb(JabberStream *js, xmlnode *packet, gpointer data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
653 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
654 JabberIq *iq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
655 xmlnode *query, *x;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
656 const char *type = xmlnode_get_attrib(packet, "type");
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
657 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
658
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
659 if(!type) {
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
660 purple_connection_error_reason (js->gc,
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
661 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
20117
f24a2cacacd1 Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <will.thompson@collabora.co.uk>
parents: 19999
diff changeset
662 _("Invalid response from server."));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
663 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
664 } else if(!strcmp(type, "error")) {
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
665 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
666 char *msg = jabber_parse_error(js, packet, &reason);
bde477ec6a71 Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <will.thompson@collabora.co.uk>
parents: 20792
diff changeset
667 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
668 g_free(msg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
669 } else if(!strcmp(type, "result")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
670 query = xmlnode_get_child(packet, "query");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
671 if(js->stream_id && xmlnode_get_child(query, "digest")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
672 unsigned char hashval[20];
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
673 char *s, h[41], *p;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
674 int i;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
675
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
676 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
677 query = xmlnode_get_child(iq->node, "query");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
678 x = xmlnode_new_child(query, "username");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
679 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
680 x = xmlnode_new_child(query, "resource");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
681 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
682
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
683 x = xmlnode_new_child(query, "digest");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
684 s = g_strdup_printf("%s%s", js->stream_id, pw);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
685
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
686 purple_cipher_digest_region("sha1", (guchar *)s, strlen(s),
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
687 sizeof(hashval), hashval, NULL);
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 p = h;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
690 for(i=0; i<20; i++, p+=2)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
691 snprintf(p, 3, "%02x", hashval[i]);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
692 xmlnode_insert_data(x, h, -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
693 g_free(s);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
694 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
695 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
696
21854
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
697 } else if(js->stream_id && xmlnode_get_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
698 const char *challenge;
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
699 guchar digest[16];
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
700 char h[17], *p;
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
701 int i;
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
702
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
703 challenge = xmlnode_get_attrib(xmlnode_get_child(query, "crammd5"), "challenge");
21921
cf17e6871edc Daniel pointed out that this should be digest, not &digest, because auth_hmac_md5 takes a guchar* rather than a guchar**
Evan Schoenberg <evan.s@dreskin.net>
parents: 21856
diff changeset
704 auth_hmac_md5(challenge, strlen(challenge), pw, strlen(pw), digest);
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
705
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
706 /* 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
707 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
708 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
709
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
710 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
711 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
712 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
713 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
714
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
715 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
716
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
717 /* Translate the digest to a hexadecimal notation */
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
718 p = h;
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
719 for(i=0; i<16; i++, p+=2)
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
720 snprintf(p, 3, "%02x", digest[i]);
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
721 xmlnode_insert_data(x, h, -1);
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
722
cb715de60eb2 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents: 21853
diff changeset
723 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
724 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
725
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
726 } else if(xmlnode_get_child(query, "password")) {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
727 if(js->gsc == NULL && !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
728 "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
729 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
730 js->gc->account->username);
21099
51cf02dbdb0e disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents: 21095
diff changeset
731 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
732 _("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
733 msg,
22143
70fc60344317 A few more of those "default_action" fixes
Mark Doliner <mark@kingant.net>
parents: 21949
diff changeset
734 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
735 purple_connection_get_account(js->gc), NULL, NULL,
21099
51cf02dbdb0e disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents: 21095
diff changeset
736 purple_connection_get_account(js->gc), allow_plaintext_auth,
51cf02dbdb0e disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents: 21095
diff changeset
737 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
738 g_free(msg);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
739 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
740 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
741 finish_plaintext_authentication(js);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
742 } else {
20117
f24a2cacacd1 Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <will.thompson@collabora.co.uk>
parents: 19999
diff changeset
743 purple_connection_error_reason (js->gc,
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
744 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE,
20117
f24a2cacacd1 Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <will.thompson@collabora.co.uk>
parents: 19999
diff changeset
745 _("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
746 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
747 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
748 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
749 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
750
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
751 void jabber_auth_start_old(JabberStream *js)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
752 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
753 JabberIq *iq;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
754 xmlnode *query, *username;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
755
16068
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
756 #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
757 /* 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
758 * 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
759 * password prompting here
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
760 */
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
761
16068
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
762 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
763 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
764 return;
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
765 }
ac1a32ebd62c patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15889
diff changeset
766 #endif
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
767 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
768
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
769 query = xmlnode_get_child(iq->node, "query");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
770 username = xmlnode_new_child(query, "username");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
771 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
772
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
773 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
774
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
775 jabber_iq_send(iq);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
776 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
777
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 /* 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
779 static GHashTable* parse_challenge(const char *challenge)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
780 {
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
781 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
782 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
783 g_free, g_free);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
784
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
785 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
786 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
787 /* 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
788 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
789 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
790 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
791 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
792 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
793 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
794 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
795 }
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
796
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
797 /* 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
798 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
799 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
800 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
801
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
802 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
803 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
804
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
805 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
806 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
807 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
808 || *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
809 || *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
810 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
811
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
812 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
813 while (val_end != val_start && (*val_end == ' ' || *val_end == ',' || *val_end == '\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
814 || *val_end == '\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
815 || *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
816 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
817
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
818 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
819 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
820 }
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
821
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
822 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
823 }
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
824
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
825 /* 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
826 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
827 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
828 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
829 || *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
830 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
831 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
832 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
833
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
834 return ret;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
835 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
836
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
837 static char *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
838 generate_response_value(JabberID *jid, const char *passwd, const char *nonce,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
839 const char *cnonce, const char *a2, const char *realm)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
840 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
841 PurpleCipher *cipher;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
842 PurpleCipherContext *context;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
843 guchar result[16];
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
844 size_t a1len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
845
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
846 gchar *a1, *convnode=NULL, *convpasswd = NULL, *ha1, *ha2, *kd, *x, *z;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
847
19197
47942d19f301 Use -1 as length with g_convert() functions instead of strlen()
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18861
diff changeset
848 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
849 NULL, NULL, NULL)) == NULL) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
850 convnode = g_strdup(jid->node);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
851 }
19197
47942d19f301 Use -1 as length with g_convert() functions instead of strlen()
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18861
diff changeset
852 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
853 "utf-8", NULL, NULL, NULL)) == NULL)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
854 convpasswd = g_strdup(passwd);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
855 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
856
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
857 cipher = purple_ciphers_find_cipher("md5");
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
858 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
859
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
860 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
861 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
862 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
863
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
864 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
865 a1len = strlen(a1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
866 g_memmove(a1, result, 16);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
867
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
868 purple_cipher_context_reset(context, NULL);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
869 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
870 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
871
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
872 ha1 = purple_base16_encode(result, 16);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
873
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
874 purple_cipher_context_reset(context, NULL);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
875 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
876 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
877
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
878 ha2 = purple_base16_encode(result, 16);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
879
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
880 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
881
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
882 purple_cipher_context_reset(context, NULL);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
883 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
884 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
885 purple_cipher_context_destroy(context);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
886
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
887 z = purple_base16_encode(result, 16);
15373
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 g_free(convnode);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
890 g_free(convpasswd);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
891 g_free(x);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
892 g_free(a1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
893 g_free(ha1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
894 g_free(ha2);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
895 g_free(kd);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
896
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
897 return z;
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
900 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
901 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
902 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
903
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
904 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
905 char *enc_in = xmlnode_get_data(packet);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
906 char *dec_in;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
907 char *enc_out;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
908 GHashTable *parts;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
909
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
910 if(!enc_in) {
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
911 purple_connection_error_reason (js->gc,
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
912 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
20117
f24a2cacacd1 Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <will.thompson@collabora.co.uk>
parents: 19999
diff changeset
913 _("Invalid response from server."));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
914 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
915 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
916
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
917 dec_in = (char *)purple_base64_decode(enc_in, NULL);
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
918 purple_debug(PURPLE_DEBUG_MISC, "jabber", "decoded challenge (%"
3225c99785b8 Fix a bunch of compiler warnings caused by my addition of G_GNUC_PRINTF()
Mark Doliner <mark@kingant.net>
parents: 22207
diff changeset
919 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
920
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
921 parts = parse_challenge(dec_in);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
922
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
923
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
924 if (g_hash_table_lookup(parts, "rspauth")) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
925 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
926
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
927
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
928 if(rspauth && js->expected_rspauth &&
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
929 !strcmp(rspauth, js->expected_rspauth)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
930 jabber_send_raw(js,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
931 "<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
932 -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
933 } else {
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
934 purple_connection_error_reason (js->gc,
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
935 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
20117
f24a2cacacd1 Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <will.thompson@collabora.co.uk>
parents: 19999
diff changeset
936 _("Invalid challenge from server"));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
937 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
938 g_free(js->expected_rspauth);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
939 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
940 /* assemble a response, and send it */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
941 /* see RFC 2831 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
942 char *realm;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
943 char *nonce;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
944
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
945 /* 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
946 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
947
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 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
949
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
950 /* 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
951 * 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
952 * 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
953 * someone, or I get really bored */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
954 realm = g_hash_table_lookup(parts, "realm");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
955 if(!realm)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
956 realm = js->user->domain;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
957
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
958 if (nonce == NULL || realm == NULL)
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
959 purple_connection_error_reason (js->gc,
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
960 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
20117
f24a2cacacd1 Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <will.thompson@collabora.co.uk>
parents: 19999
diff changeset
961 _("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
962 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
963 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
964 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
965 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
966 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
967 char *cnonce;
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 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
970 g_random_int());
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
971
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
972 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
973 auth_resp = generate_response_value(js->user,
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
974 purple_connection_get_password(js->gc), nonce, cnonce, a2, 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
975 g_free(a2);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
976
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
977 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
978 js->expected_rspauth = generate_response_value(js->user,
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
979 purple_connection_get_password(js->gc), nonce, cnonce, a2, 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
980 g_free(a2);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
981
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
982 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
983 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
984 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
985 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
986 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
987 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
988 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
989 g_string_append_printf(response, ",response=%s", 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
990 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
991
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
992 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
993 g_free(cnonce);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
994
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
995 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
996
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
997 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
998 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
999 response->len, response->str);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1000
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
1001 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
1002
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
1003 jabber_send_raw(js, buf, -1);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1004
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
1005 g_free(buf);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1006
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
1007 g_free(enc_out);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1008
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
1009 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
1010 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1011 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1012
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1013 g_free(enc_in);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1014 g_free(dec_in);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1015 g_hash_table_destroy(parts);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1016 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1017 #ifdef HAVE_CYRUS_SASL
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1018 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
1019 char *enc_in = xmlnode_get_data(packet);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1020 unsigned char *dec_in;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1021 char *enc_out;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1022 const char *c_out;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1023 unsigned int clen;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1024 gsize declen;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1025 xmlnode *response;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1026
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
1027 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
1028
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1029 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
1030 NULL, &c_out, &clen);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1031 g_free(enc_in);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1032 g_free(dec_in);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1033 if (js->sasl_state != SASL_CONTINUE && js->sasl_state != SASL_OK) {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
1034 purple_debug_error("jabber", "Error is %d : %s\n",js->sasl_state,sasl_errdetail(js->sasl));
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
1035 purple_connection_error_reason (js->gc,
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
1036 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
20117
f24a2cacacd1 Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <will.thompson@collabora.co.uk>
parents: 19999
diff changeset
1037 _("SASL error"));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1038 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1039 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1040 response = xmlnode_new("response");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1041 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
1042 if (clen > 0) {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
1043 enc_out = purple_base64_encode((unsigned char*)c_out, clen);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1044 xmlnode_insert_data(response, enc_out, -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1045 g_free(enc_out);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1046 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1047 jabber_send(js, response);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1048 xmlnode_free(response);
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 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1051 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1052 }
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 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
1055 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1056 const char *ns = xmlnode_get_namespace(packet);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1057 #ifdef HAVE_CYRUS_SASL
16316
c1f2831c1afe Get rid of two really minor warnings
Mark Doliner <mark@kingant.net>
parents: 16068
diff changeset
1058 const void *x;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1059 #endif
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(!ns || strcmp(ns, "urn:ietf:params:xml:ns:xmpp-sasl")) {
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
1062 purple_connection_error_reason (js->gc,
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
1063 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
20117
f24a2cacacd1 Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <will.thompson@collabora.co.uk>
parents: 19999
diff changeset
1064 _("Invalid response from server."));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1065 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1066 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1067
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1068 #ifdef HAVE_CYRUS_SASL
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1069 /* 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
1070 * should try one more round against it
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1071 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1072 if (js->sasl_state != SASL_OK) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1073 char *enc_in = xmlnode_get_data(packet);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1074 unsigned char *dec_in = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1075 const char *c_out;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1076 unsigned int clen;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1077 gsize declen = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1078
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1079 if(enc_in != NULL)
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15765
diff changeset
1080 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
1081
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1082 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
1083
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1084 g_free(enc_in);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1085 g_free(dec_in);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1086
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1087 if (js->sasl_state != SASL_OK) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1088 /* This should never happen! */
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
1089 purple_connection_error_reason (js->gc,
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
1090 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
20117
f24a2cacacd1 Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <will.thompson@collabora.co.uk>
parents: 19999
diff changeset
1091 _("Invalid response from server."));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1092 }
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 /* 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
1095 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
1096 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
1097 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
1098 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
1099 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
1100 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1101 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1102 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1103
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1104 jabber_stream_set_state(js, JABBER_STREAM_REINITIALIZING);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1105 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1106
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1107 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
1108 {
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
1109 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
1110 char *msg;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1111
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
1112 #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
1113 if(js->auth_fail_count++ < 5) {
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
1114 if (js->current_mech && strlen(js->current_mech) > 0) {
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
1115 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
1116 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
1117 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
1118 }
22767
d5b3afea8764 After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evan.s@dreskin.net>
parents: 22672
diff changeset
1119 /* Remove space which separated this mech from the next */
d5b3afea8764 After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evan.s@dreskin.net>
parents: 22672
diff changeset
1120 if (strlen(js->sasl_mechs->str) > 0 && ((js->sasl_mechs->str)[0] == ' ')) {
d5b3afea8764 After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evan.s@dreskin.net>
parents: 22672
diff changeset
1121 g_string_erase(js->sasl_mechs, 0, 1);
d5b3afea8764 After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evan.s@dreskin.net>
parents: 22672
diff changeset
1122 }
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
1123 }
22767
d5b3afea8764 After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evan.s@dreskin.net>
parents: 22672
diff changeset
1124 if (strlen(js->sasl_mechs->str)) {
d5b3afea8764 After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evan.s@dreskin.net>
parents: 22672
diff changeset
1125 /* 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
1126 sasl_dispose(&js->sasl);
d5b3afea8764 After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evan.s@dreskin.net>
parents: 22672
diff changeset
1127
d5b3afea8764 After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evan.s@dreskin.net>
parents: 22672
diff changeset
1128 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
1129 return;
d5b3afea8764 After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evan.s@dreskin.net>
parents: 22672
diff changeset
1130 }
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
1131 }
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
1132 #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
1133 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
1134 if(!msg) {
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
1135 purple_connection_error_reason (js->gc,
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20815
diff changeset
1136 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
20117
f24a2cacacd1 Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <will.thompson@collabora.co.uk>
parents: 19999
diff changeset
1137 _("Invalid response from server."));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1138 } else {
20814
bde477ec6a71 Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <will.thompson@collabora.co.uk>
parents: 20792
diff changeset
1139 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
1140 g_free(msg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1141 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1142 }