Mercurial > pidgin
annotate libpurple/protocols/jabber/auth.c @ 28878:c64b22932ffa
Cyrus may not have anything (yet) if it's waiting for a callback or something.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Wed, 13 Jan 2010 03:13:26 +0000 |
parents | b94fd073187c |
children | 9f59abd49def |
rev | line source |
---|---|
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1 /* |
15822 | 2 * purple - Jabber Protocol Plugin |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3 * |
28048
c585572e80dd
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents:
27381
diff
changeset
|
4 * Purple is the legal property of its developers, whose names are too numerous |
c585572e80dd
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents:
27381
diff
changeset
|
5 * to list here. Please refer to the COPYRIGHT file distributed with this |
c585572e80dd
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents:
27381
diff
changeset
|
6 * source distribution. |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
7 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
8 * This program is free software; you can redistribute it and/or modify |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
9 * it under the terms of the GNU General Public License as published by |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
10 * the Free Software Foundation; either version 2 of the License, or |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
11 * (at your option) any later version. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
12 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
16 * GNU General Public License for more details. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
17 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
18 * You should have received a copy of the GNU General Public License |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
19 * along with this program; if not, write to the Free Software |
19681
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19675
diff
changeset
|
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
21 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
22 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
23 #include "internal.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
24 |
15889
87ea711b9781
Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <stu@nosnilmot.com>
parents:
15822
diff
changeset
|
25 #include "account.h" |
87ea711b9781
Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <stu@nosnilmot.com>
parents:
15822
diff
changeset
|
26 #include "debug.h" |
87ea711b9781
Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <stu@nosnilmot.com>
parents:
15822
diff
changeset
|
27 #include "cipher.h" |
20152
0cb113dfb096
Disable the account when the user cancels entering the password so the account isn't stuck in a weird unconnected state. Fixes #1791
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19999
diff
changeset
|
28 #include "core.h" |
15889
87ea711b9781
Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <stu@nosnilmot.com>
parents:
15822
diff
changeset
|
29 #include "conversation.h" |
87ea711b9781
Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <stu@nosnilmot.com>
parents:
15822
diff
changeset
|
30 #include "request.h" |
87ea711b9781
Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <stu@nosnilmot.com>
parents:
15822
diff
changeset
|
31 #include "sslconn.h" |
87ea711b9781
Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <stu@nosnilmot.com>
parents:
15822
diff
changeset
|
32 #include "util.h" |
87ea711b9781
Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <stu@nosnilmot.com>
parents:
15822
diff
changeset
|
33 #include "xmlnode.h" |
87ea711b9781
Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <stu@nosnilmot.com>
parents:
15822
diff
changeset
|
34 |
26460
680b54e417c1
Make the last one compile (add disco.h) and alphabetize.
Paul Aurich <paul@darkrain42.org>
parents:
26458
diff
changeset
|
35 #include "auth.h" |
680b54e417c1
Make the last one compile (add disco.h) and alphabetize.
Paul Aurich <paul@darkrain42.org>
parents:
26458
diff
changeset
|
36 #include "disco.h" |
680b54e417c1
Make the last one compile (add disco.h) and alphabetize.
Paul Aurich <paul@darkrain42.org>
parents:
26458
diff
changeset
|
37 #include "jabber.h" |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
38 #include "jutil.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
39 #include "iq.h" |
16068
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15889
diff
changeset
|
40 #include "notify.h" |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
41 |
28696
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
42 static GSList *auth_mechs = NULL; |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
43 |
26465
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25952
diff
changeset
|
44 static void auth_old_result_cb(JabberStream *js, const char *from, |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25952
diff
changeset
|
45 JabberIqType type, const char *id, |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25952
diff
changeset
|
46 xmlnode *packet, gpointer data); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
47 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
48 gboolean |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
49 jabber_process_starttls(JabberStream *js, xmlnode *packet) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
50 { |
28697
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
28696
diff
changeset
|
51 PurpleAccount *account; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
52 xmlnode *starttls; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
53 |
28697
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
28696
diff
changeset
|
54 account = purple_connection_get_account(js->gc); |
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
28696
diff
changeset
|
55 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
56 if((starttls = xmlnode_get_child(packet, "starttls"))) { |
15822 | 57 if(purple_ssl_is_supported()) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
58 jabber_send_raw(js, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
59 "<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
|
60 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
61 } else if(xmlnode_get_child(starttls, "required")) { |
27381
f541583e31bd
More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents:
27379
diff
changeset
|
62 purple_connection_error_reason(js->gc, |
21358 | 63 PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT, |
27378
6275df9d2d62
Change strings in libpurple/protocols/jabber/auth.c and util.c a little bit
Mark Doliner <mark@kingant.net>
parents:
27151
diff
changeset
|
64 _("Server requires TLS/SSL, but no TLS/SSL support was found.")); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
65 return TRUE; |
28697
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
28696
diff
changeset
|
66 } else if(purple_account_get_bool(account, "require_tls", JABBER_DEFAULT_REQUIRE_TLS)) { |
27381
f541583e31bd
More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents:
27379
diff
changeset
|
67 purple_connection_error_reason(js->gc, |
22800
abd261518b83
When an XMPP account is set to require TLS, but libpurple doesn't have SSL
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22672
diff
changeset
|
68 PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT, |
27378
6275df9d2d62
Change strings in libpurple/protocols/jabber/auth.c and util.c a little bit
Mark Doliner <mark@kingant.net>
parents:
27151
diff
changeset
|
69 _("You require encryption, but no TLS/SSL support was found.")); |
22800
abd261518b83
When an XMPP account is set to require TLS, but libpurple doesn't have SSL
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22672
diff
changeset
|
70 return TRUE; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
71 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
72 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
73 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
74 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
75 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
76 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
77 static void finish_plaintext_authentication(JabberStream *js) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
78 { |
28696
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
79 JabberIq *iq; |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
80 xmlnode *query, *x; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
81 |
28696
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
82 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:auth"); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
83 query = xmlnode_get_child(iq->node, "query"); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
84 x = xmlnode_new_child(query, "username"); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
85 xmlnode_insert_data(x, js->user->node, -1); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
86 x = xmlnode_new_child(query, "resource"); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
87 xmlnode_insert_data(x, js->user->resource, -1); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
88 x = xmlnode_new_child(query, "password"); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
89 xmlnode_insert_data(x, purple_connection_get_password(js->gc), -1); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
90 jabber_iq_set_callback(iq, auth_old_result_cb, NULL); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
91 jabber_iq_send(iq); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
92 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
93 |
15822 | 94 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
|
95 { |
28697
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
28696
diff
changeset
|
96 PurpleConnection *gc; |
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
28696
diff
changeset
|
97 JabberStream *js; |
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
28696
diff
changeset
|
98 |
15822 | 99 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
|
100 |
28697
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
28696
diff
changeset
|
101 gc = purple_account_get_connection(account); |
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
28696
diff
changeset
|
102 js = purple_connection_get_protocol_data(gc); |
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
28696
diff
changeset
|
103 |
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
28696
diff
changeset
|
104 finish_plaintext_authentication(js); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
105 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
106 |
15822 | 107 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
|
108 { |
28697
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
28696
diff
changeset
|
109 purple_connection_error_reason(purple_account_get_connection(account), |
21358 | 110 PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR, |
20117
f24a2cacacd1
Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <will.thompson@collabora.co.uk>
parents:
19999
diff
changeset
|
111 _("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
|
112 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
113 |
28715
cea22db36ffc
jabber: Use NS_XMPP_SASL
Paul Aurich <paul@darkrain42.org>
parents:
28707
diff
changeset
|
114 #ifdef HAVE_CYRUS_SASL |
28696
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
115 static void |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
116 auth_old_pass_cb(PurpleConnection *gc, PurpleRequestFields *fields) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
117 { |
28696
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
118 PurpleAccount *account; |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
119 JabberStream *js; |
16068
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15889
diff
changeset
|
120 const char *entry; |
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15889
diff
changeset
|
121 gboolean remember; |
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15889
diff
changeset
|
122 |
28696
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
123 /* The password prompt dialog doesn't get disposed if the account disconnects */ |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
124 if (!PURPLE_CONNECTION_IS_VALID(gc)) |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
125 return; |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
126 |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
127 account = purple_connection_get_account(gc); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
128 js = purple_connection_get_protocol_data(gc); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
129 |
16068
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15889
diff
changeset
|
130 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
|
131 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
|
132 |
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15889
diff
changeset
|
133 if (!entry || !*entry) |
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15889
diff
changeset
|
134 { |
28696
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
135 purple_notify_error(account, NULL, _("Password is required to sign on."), NULL); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
136 return; |
16068
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15889
diff
changeset
|
137 } |
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15889
diff
changeset
|
138 |
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15889
diff
changeset
|
139 if (remember) |
28696
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
140 purple_account_set_remember_password(account, TRUE); |
16068
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15889
diff
changeset
|
141 |
28696
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
142 purple_account_set_password(account, entry); |
20152
0cb113dfb096
Disable the account when the user cancels entering the password so the account isn't stuck in a weird unconnected state. Fixes #1791
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19999
diff
changeset
|
143 |
16068
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15889
diff
changeset
|
144 /* Restart our connection */ |
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15889
diff
changeset
|
145 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
|
146 } |
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15889
diff
changeset
|
147 |
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15889
diff
changeset
|
148 static void |
28697
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
28696
diff
changeset
|
149 auth_no_pass_cb(PurpleConnection *gc, PurpleRequestFields *fields) |
16068
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15889
diff
changeset
|
150 { |
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
|
151 /* The password prompt dialog doesn't get disposed if the account disconnects */ |
28697
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
28696
diff
changeset
|
152 if (!PURPLE_CONNECTION_IS_VALID(gc)) |
19675
55c47f7ab2a2
The cyrus SASL password prompt dialogs don't get disposed if the account disconnects. This fixes the callbacks not to assume that the connection is still valid.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
19197
diff
changeset
|
153 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
|
154 |
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
|
155 /* Disable the account as the user has canceled connecting */ |
28697
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
28696
diff
changeset
|
156 purple_account_set_enabled(purple_connection_get_account(gc), purple_core_get_ui(), FALSE); |
16068
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15889
diff
changeset
|
157 } |
28715
cea22db36ffc
jabber: Use NS_XMPP_SASL
Paul Aurich <paul@darkrain42.org>
parents:
28707
diff
changeset
|
158 #endif |
16068
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15889
diff
changeset
|
159 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
160 void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
161 jabber_auth_start(JabberStream *js, xmlnode *packet) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
162 { |
28696
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
163 GSList *mechanisms = NULL; |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
164 GSList *l; |
28725
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
28715
diff
changeset
|
165 xmlnode *response = NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
166 xmlnode *mechs, *mechnode; |
28725
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
28715
diff
changeset
|
167 JabberSaslState state; |
28754
b94fd073187c
jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <paul@darkrain42.org>
parents:
28725
diff
changeset
|
168 char *msg = NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
169 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
170 if(js->registration) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
171 jabber_register_start(js); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
172 return; |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
175 mechs = xmlnode_get_child(packet, "mechanisms"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
176 if(!mechs) { |
27381
f541583e31bd
More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents:
27379
diff
changeset
|
177 purple_connection_error_reason(js->gc, |
21358 | 178 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
27381
f541583e31bd
More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents:
27379
diff
changeset
|
179 _("Invalid response from server")); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
180 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
181 } |
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 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
|
184 mechnode = xmlnode_get_next_twin(mechnode)) |
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 char *mech_name = xmlnode_get_data(mechnode); |
23075
9d331ad0a8dc
Skip the X-GOOGLE-TOKEN mech (given us by Google Talk when connecting with
Evan Schoenberg <evan.s@dreskin.net>
parents:
22819
diff
changeset
|
187 |
28696
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
188 if (mech_name && *mech_name) |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
189 mechanisms = g_slist_prepend(mechanisms, mech_name); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
190 else if (mech_name) |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
191 g_free(mech_name); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
192 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
193 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
194 |
28696
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
195 for (l = auth_mechs; l; l = l->next) { |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
196 JabberSaslMech *possible = l->data; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
197 |
28696
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
198 /* Is this the Cyrus SASL mechanism? */ |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
199 if (g_str_equal(possible->name, "*")) { |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
200 js->auth_mech = possible; |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
201 break; |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
202 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
203 |
28696
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
204 /* Can we find this mechanism in the server's list? */ |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
205 if (g_slist_find_custom(mechanisms, possible->name, (GCompareFunc)strcmp)) { |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
206 js->auth_mech = possible; |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
207 break; |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
208 } |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
209 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
210 |
28696
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
211 if (js->auth_mech == NULL) { |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
212 /* Found no good mechanisms... */ |
27381
f541583e31bd
More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents:
27379
diff
changeset
|
213 purple_connection_error_reason(js->gc, |
21358 | 214 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
215 _("Server does not use any supported authentication method")); |
28696
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
216 return; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
217 } |
28696
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
218 |
28725
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
28715
diff
changeset
|
219 state = js->auth_mech->start(js, mechs, &response, &msg); |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
28715
diff
changeset
|
220 if (state == JABBER_SASL_STATE_FAIL) { |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
28715
diff
changeset
|
221 purple_connection_error_reason(js->gc, |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
28715
diff
changeset
|
222 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
28715
diff
changeset
|
223 msg ? msg : _("Unknown Error")); |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
28715
diff
changeset
|
224 } else if (response) { |
28696
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
225 jabber_send(js, response); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
226 xmlnode_free(response); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
227 } |
28754
b94fd073187c
jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <paul@darkrain42.org>
parents:
28725
diff
changeset
|
228 |
b94fd073187c
jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <paul@darkrain42.org>
parents:
28725
diff
changeset
|
229 g_free(msg); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
230 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
231 |
26465
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25952
diff
changeset
|
232 static void auth_old_result_cb(JabberStream *js, const char *from, |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25952
diff
changeset
|
233 JabberIqType type, const char *id, |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25952
diff
changeset
|
234 xmlnode *packet, gpointer data) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
235 { |
26465
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25952
diff
changeset
|
236 if (type == JABBER_IQ_RESULT) { |
28096
b357216b7b79
jabber: Fix using BOSH and legacy auth together. Closes #9990.
Paul Aurich <paul@darkrain42.org>
parents:
28048
diff
changeset
|
237 jabber_stream_set_state(js, JABBER_STREAM_POST_AUTH); |
26458
f25410b0827c
Fix login process for older servers using IQ-auth.
Paul Aurich <paul@darkrain42.org>
parents:
26272
diff
changeset
|
238 jabber_disco_items_server(js); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
239 } else { |
28697
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
28696
diff
changeset
|
240 PurpleAccount *account; |
21358 | 241 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
|
242 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
|
243 xmlnode *error; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
244 const char *err_code; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
245 |
28699 | 246 account = purple_connection_get_account(js->gc); |
28697
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
28696
diff
changeset
|
247 |
20814
bde477ec6a71
Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <will.thompson@collabora.co.uk>
parents:
20792
diff
changeset
|
248 /* 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
|
249 if((error = xmlnode_get_child(packet, "error")) && |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
250 (err_code = xmlnode_get_attrib(error, "code")) && |
28514
5328e205d3fb
jabber: Use purple_strequal to simplify some auth code
Paul Aurich <paul@darkrain42.org>
parents:
28513
diff
changeset
|
251 g_str_equal(err_code, "401")) { |
21358 | 252 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
|
253 /* Clear the pasword if it isn't being saved */ |
28697
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
28696
diff
changeset
|
254 if (!purple_account_get_remember_password(account)) |
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
28696
diff
changeset
|
255 purple_account_set_password(account, NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
256 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
257 |
27381
f541583e31bd
More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents:
27379
diff
changeset
|
258 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
|
259 g_free(msg); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
260 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
261 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
262 |
26465
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25952
diff
changeset
|
263 static void auth_old_cb(JabberStream *js, const char *from, |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25952
diff
changeset
|
264 JabberIqType type, const char *id, |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25952
diff
changeset
|
265 xmlnode *packet, gpointer data) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
266 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
267 JabberIq *iq; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
268 xmlnode *query, *x; |
15822 | 269 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
|
270 |
26465
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25952
diff
changeset
|
271 if (type == JABBER_IQ_ERROR) { |
21358 | 272 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
|
273 char *msg = jabber_parse_error(js, packet, &reason); |
27381
f541583e31bd
More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents:
27379
diff
changeset
|
274 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
|
275 g_free(msg); |
26465
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25952
diff
changeset
|
276 } else if (type == JABBER_IQ_RESULT) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
277 query = xmlnode_get_child(packet, "query"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
278 if(js->stream_id && xmlnode_get_child(query, "digest")) { |
24693
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
24565
diff
changeset
|
279 char *s, *hash; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
280 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
281 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
|
282 query = xmlnode_get_child(iq->node, "query"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
283 x = xmlnode_new_child(query, "username"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
284 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
|
285 x = xmlnode_new_child(query, "resource"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
286 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
|
287 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
288 x = xmlnode_new_child(query, "digest"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
289 s = g_strdup_printf("%s%s", js->stream_id, pw); |
24693
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
24565
diff
changeset
|
290 hash = jabber_calculate_data_sha1sum(s, strlen(s)); |
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
24565
diff
changeset
|
291 xmlnode_insert_data(x, hash, -1); |
61e0924de04a
Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <paul@darkrain42.org>
parents:
24565
diff
changeset
|
292 g_free(hash); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
293 g_free(s); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
294 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
|
295 jabber_iq_send(iq); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
296 |
23264
2b997b690500
A patch from QuLogic to eliminate duplicated HMAC-MD5 code in the Jabber
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23256
diff
changeset
|
297 } else if(js->stream_id && (x = xmlnode_get_child(query, "crammd5"))) { |
21854
cb715de60eb2
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents:
21853
diff
changeset
|
298 const char *challenge; |
23264
2b997b690500
A patch from QuLogic to eliminate duplicated HMAC-MD5 code in the Jabber
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23256
diff
changeset
|
299 gchar digest[33]; |
2b997b690500
A patch from QuLogic to eliminate duplicated HMAC-MD5 code in the Jabber
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23256
diff
changeset
|
300 PurpleCipherContext *hmac; |
21854
cb715de60eb2
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents:
21853
diff
changeset
|
301 |
23264
2b997b690500
A patch from QuLogic to eliminate duplicated HMAC-MD5 code in the Jabber
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23256
diff
changeset
|
302 /* Calculate the MHAC-MD5 digest */ |
2b997b690500
A patch from QuLogic to eliminate duplicated HMAC-MD5 code in the Jabber
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23256
diff
changeset
|
303 challenge = xmlnode_get_attrib(x, "challenge"); |
2b997b690500
A patch from QuLogic to eliminate duplicated HMAC-MD5 code in the Jabber
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23256
diff
changeset
|
304 hmac = purple_cipher_context_new_by_name("hmac", NULL); |
2b997b690500
A patch from QuLogic to eliminate duplicated HMAC-MD5 code in the Jabber
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23256
diff
changeset
|
305 purple_cipher_context_set_option(hmac, "hash", "md5"); |
2b997b690500
A patch from QuLogic to eliminate duplicated HMAC-MD5 code in the Jabber
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23256
diff
changeset
|
306 purple_cipher_context_set_key(hmac, (guchar *)pw); |
2b997b690500
A patch from QuLogic to eliminate duplicated HMAC-MD5 code in the Jabber
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23256
diff
changeset
|
307 purple_cipher_context_append(hmac, (guchar *)challenge, strlen(challenge)); |
2b997b690500
A patch from QuLogic to eliminate duplicated HMAC-MD5 code in the Jabber
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23256
diff
changeset
|
308 purple_cipher_context_digest_to_str(hmac, 33, digest, NULL); |
2b997b690500
A patch from QuLogic to eliminate duplicated HMAC-MD5 code in the Jabber
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23256
diff
changeset
|
309 purple_cipher_context_destroy(hmac); |
21856
2e899bbbf14c
Last minute 'cleanup' actually resulted in breakage on my cram-md5 commit. Fixed it.
Evan Schoenberg <evan.s@dreskin.net>
parents:
21854
diff
changeset
|
310 |
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
|
311 /* 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
|
312 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
|
313 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
|
314 |
cb715de60eb2
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents:
21853
diff
changeset
|
315 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
|
316 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
|
317 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
|
318 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
|
319 |
cb715de60eb2
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents:
21853
diff
changeset
|
320 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
|
321 |
23264
2b997b690500
A patch from QuLogic to eliminate duplicated HMAC-MD5 code in the Jabber
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
23256
diff
changeset
|
322 xmlnode_insert_data(x, digest, 32); |
21854
cb715de60eb2
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents:
21853
diff
changeset
|
323 |
cb715de60eb2
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evan.s@dreskin.net>
parents:
21853
diff
changeset
|
324 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
|
325 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
|
326 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
327 } else if(xmlnode_get_child(query, "password")) { |
28697
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
28696
diff
changeset
|
328 PurpleAccount *account = purple_connection_get_account(js->gc); |
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
28696
diff
changeset
|
329 if(!jabber_stream_is_ssl(js) && !purple_account_get_bool(account, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
330 "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
|
331 char *msg = g_strdup_printf(_("%s requires plaintext authentication over an unencrypted connection. Allow this and continue authentication?"), |
28697
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
28696
diff
changeset
|
332 purple_account_get_username(account)); |
21099
51cf02dbdb0e
disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents:
21095
diff
changeset
|
333 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
|
334 _("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
|
335 msg, |
22143
70fc60344317
A few more of those "default_action" fixes
Mark Doliner <mark@kingant.net>
parents:
21949
diff
changeset
|
336 1, |
28697
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
28696
diff
changeset
|
337 account, NULL, NULL, |
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
28696
diff
changeset
|
338 account, allow_plaintext_auth, |
21099
51cf02dbdb0e
disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents:
21095
diff
changeset
|
339 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
|
340 g_free(msg); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
341 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
342 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
343 finish_plaintext_authentication(js); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
344 } else { |
27381
f541583e31bd
More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents:
27379
diff
changeset
|
345 purple_connection_error_reason(js->gc, |
21358 | 346 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, |
20117
f24a2cacacd1
Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <will.thompson@collabora.co.uk>
parents:
19999
diff
changeset
|
347 _("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
|
348 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
349 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
350 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
351 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
352 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
353 void jabber_auth_start_old(JabberStream *js) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
354 { |
28697
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
28696
diff
changeset
|
355 PurpleAccount *account; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
356 JabberIq *iq; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
357 xmlnode *query, *username; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
358 |
28697
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
28696
diff
changeset
|
359 account = purple_connection_get_account(js->gc); |
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
28696
diff
changeset
|
360 |
28292
fa77b70c8ca6
jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents:
28096
diff
changeset
|
361 /* |
fa77b70c8ca6
jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents:
28096
diff
changeset
|
362 * We can end up here without encryption if the server doesn't support |
26947
131e41a24d95
Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <paul@darkrain42.org>
parents:
26487
diff
changeset
|
363 * <stream:features/> and we're not using old-style SSL. If the user |
131e41a24d95
Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <paul@darkrain42.org>
parents:
26487
diff
changeset
|
364 * is requiring SSL/TLS, we need to enforce it. |
131e41a24d95
Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <paul@darkrain42.org>
parents:
26487
diff
changeset
|
365 */ |
131e41a24d95
Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <paul@darkrain42.org>
parents:
26487
diff
changeset
|
366 if (!jabber_stream_is_ssl(js) && |
28697
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
28696
diff
changeset
|
367 purple_account_get_bool(account, "require_tls", JABBER_DEFAULT_REQUIRE_TLS)) { |
27381
f541583e31bd
More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents:
27379
diff
changeset
|
368 purple_connection_error_reason(js->gc, |
26947
131e41a24d95
Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <paul@darkrain42.org>
parents:
26487
diff
changeset
|
369 PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR, |
131e41a24d95
Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <paul@darkrain42.org>
parents:
26487
diff
changeset
|
370 _("You require encryption, but it is not available on this server.")); |
131e41a24d95
Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <paul@darkrain42.org>
parents:
26487
diff
changeset
|
371 return; |
131e41a24d95
Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <paul@darkrain42.org>
parents:
26487
diff
changeset
|
372 } |
131e41a24d95
Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <paul@darkrain42.org>
parents:
26487
diff
changeset
|
373 |
28696
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
374 if (js->registration) { |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
375 jabber_register_start(js); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
376 return; |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
377 } |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
378 |
28292
fa77b70c8ca6
jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents:
28096
diff
changeset
|
379 /* |
fa77b70c8ca6
jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents:
28096
diff
changeset
|
380 * IQ Auth doesn't have support for resource binding, so we need to pick a |
fa77b70c8ca6
jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents:
28096
diff
changeset
|
381 * default resource so it will work properly. jabberd14 throws an error and |
fa77b70c8ca6
jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents:
28096
diff
changeset
|
382 * iChat server just fails silently. |
fa77b70c8ca6
jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents:
28096
diff
changeset
|
383 */ |
fa77b70c8ca6
jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents:
28096
diff
changeset
|
384 if (!js->user->resource || *js->user->resource == '\0') { |
fa77b70c8ca6
jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents:
28096
diff
changeset
|
385 g_free(js->user->resource); |
fa77b70c8ca6
jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents:
28096
diff
changeset
|
386 js->user->resource = g_strdup("Home"); |
fa77b70c8ca6
jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents:
28096
diff
changeset
|
387 } |
fa77b70c8ca6
jabber: Always require a resource when starting Legacy IQ Auth.
Paul Aurich <paul@darkrain42.org>
parents:
28096
diff
changeset
|
388 |
16068
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15889
diff
changeset
|
389 #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
|
390 /* 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
|
391 * 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
|
392 * password prompting here |
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15889
diff
changeset
|
393 */ |
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
|
394 |
28697
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
28696
diff
changeset
|
395 if (!purple_account_get_password(account)) { |
de8565bc63fe
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <paul@darkrain42.org>
parents:
28696
diff
changeset
|
396 purple_account_request_password(account, G_CALLBACK(auth_old_pass_cb), G_CALLBACK(auth_no_pass_cb), js->gc); |
16068
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15889
diff
changeset
|
397 return; |
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15889
diff
changeset
|
398 } |
ac1a32ebd62c
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15889
diff
changeset
|
399 #endif |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
400 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
|
401 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
402 query = xmlnode_get_child(iq->node, "query"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
403 username = xmlnode_new_child(query, "username"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
404 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
|
405 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
406 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
|
407 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
408 jabber_iq_send(iq); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
409 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
410 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
411 void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
412 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
|
413 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
414 const char *ns = xmlnode_get_namespace(packet); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
415 |
28715
cea22db36ffc
jabber: Use NS_XMPP_SASL
Paul Aurich <paul@darkrain42.org>
parents:
28707
diff
changeset
|
416 if (!purple_strequal(ns, NS_XMPP_SASL)) { |
27381
f541583e31bd
More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents:
27379
diff
changeset
|
417 purple_connection_error_reason(js->gc, |
21358 | 418 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
27381
f541583e31bd
More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents:
27379
diff
changeset
|
419 _("Invalid response from server")); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
420 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
421 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
422 |
28696
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
423 if (js->auth_mech && js->auth_mech->handle_challenge) { |
28725
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
28715
diff
changeset
|
424 xmlnode *response = NULL; |
28754
b94fd073187c
jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <paul@darkrain42.org>
parents:
28725
diff
changeset
|
425 char *msg = NULL; |
28725
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
28715
diff
changeset
|
426 JabberSaslState state = js->auth_mech->handle_challenge(js, packet, &response, &msg); |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
28715
diff
changeset
|
427 if (state == JABBER_SASL_STATE_FAIL) { |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
28715
diff
changeset
|
428 purple_connection_error_reason(js->gc, |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
28715
diff
changeset
|
429 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
28715
diff
changeset
|
430 msg ? msg : _("Invalid challenge from server")); |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
28715
diff
changeset
|
431 } else if (response) { |
28696
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
432 jabber_send(js, response); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
433 xmlnode_free(response); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
434 } |
28754
b94fd073187c
jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <paul@darkrain42.org>
parents:
28725
diff
changeset
|
435 |
b94fd073187c
jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <paul@darkrain42.org>
parents:
28725
diff
changeset
|
436 g_free(msg); |
28696
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
437 } else |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
438 purple_debug_warning("jabber", "Received unexpected (and unhandled) <challenge/>\n"); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
439 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
440 |
28696
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
441 void jabber_auth_handle_success(JabberStream *js, xmlnode *packet) |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
442 { |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
443 const char *ns = xmlnode_get_namespace(packet); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
444 |
28715
cea22db36ffc
jabber: Use NS_XMPP_SASL
Paul Aurich <paul@darkrain42.org>
parents:
28707
diff
changeset
|
445 if (!purple_strequal(ns, NS_XMPP_SASL)) { |
28696
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
446 purple_connection_error_reason(js->gc, |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
447 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
448 _("Invalid response from server")); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
449 return; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
450 } |
28696
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
451 |
28725
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
28715
diff
changeset
|
452 if (js->auth_mech && js->auth_mech->handle_success) { |
28754
b94fd073187c
jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <paul@darkrain42.org>
parents:
28725
diff
changeset
|
453 char *msg = NULL; |
28725
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
28715
diff
changeset
|
454 JabberSaslState state = js->auth_mech->handle_success(js, packet, &msg); |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
28715
diff
changeset
|
455 |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
28715
diff
changeset
|
456 if (state == JABBER_SASL_STATE_FAIL) { |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
28715
diff
changeset
|
457 purple_connection_error_reason(js->gc, |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
28715
diff
changeset
|
458 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
28715
diff
changeset
|
459 msg ? msg : _("Invalid response from server")); |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
28715
diff
changeset
|
460 return; |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
28715
diff
changeset
|
461 } else if (state == JABBER_SASL_STATE_CONTINUE) { |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
28715
diff
changeset
|
462 purple_connection_error_reason(js->gc, |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
28715
diff
changeset
|
463 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
28715
diff
changeset
|
464 msg ? msg : _("Server thinks authentication is complete, but client does not")); |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
28715
diff
changeset
|
465 return; |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
28715
diff
changeset
|
466 } |
28754
b94fd073187c
jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <paul@darkrain42.org>
parents:
28725
diff
changeset
|
467 |
b94fd073187c
jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <paul@darkrain42.org>
parents:
28725
diff
changeset
|
468 g_free(msg); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
469 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
470 |
28096
b357216b7b79
jabber: Fix using BOSH and legacy auth together. Closes #9990.
Paul Aurich <paul@darkrain42.org>
parents:
28048
diff
changeset
|
471 /* |
b357216b7b79
jabber: Fix using BOSH and legacy auth together. Closes #9990.
Paul Aurich <paul@darkrain42.org>
parents:
28048
diff
changeset
|
472 * The stream will be reinitialized later in jabber_recv_cb_ssl() or |
b357216b7b79
jabber: Fix using BOSH and legacy auth together. Closes #9990.
Paul Aurich <paul@darkrain42.org>
parents:
28048
diff
changeset
|
473 * jabber_bosh_connection_send. |
b357216b7b79
jabber: Fix using BOSH and legacy auth together. Closes #9990.
Paul Aurich <paul@darkrain42.org>
parents:
28048
diff
changeset
|
474 */ |
b357216b7b79
jabber: Fix using BOSH and legacy auth together. Closes #9990.
Paul Aurich <paul@darkrain42.org>
parents:
28048
diff
changeset
|
475 js->reinit = TRUE; |
b357216b7b79
jabber: Fix using BOSH and legacy auth together. Closes #9990.
Paul Aurich <paul@darkrain42.org>
parents:
28048
diff
changeset
|
476 jabber_stream_set_state(js, JABBER_STREAM_POST_AUTH); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
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 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
|
480 { |
21358 | 481 PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR; |
28754
b94fd073187c
jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <paul@darkrain42.org>
parents:
28725
diff
changeset
|
482 char *msg = NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
483 |
28696
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
484 if (js->auth_mech && js->auth_mech->handle_failure) { |
28725
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
28715
diff
changeset
|
485 xmlnode *stanza = NULL; |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
28715
diff
changeset
|
486 JabberSaslState state = js->auth_mech->handle_failure(js, packet, &stanza, &msg); |
4f45aae3ace1
Let's try a more complex set of return states / values for auth mechs.
Paul Aurich <paul@darkrain42.org>
parents:
28715
diff
changeset
|
487 |
28878
c64b22932ffa
Cyrus may not have anything (yet) if it's waiting for a callback or something.
Paul Aurich <paul@darkrain42.org>
parents:
28754
diff
changeset
|
488 if (state != JABBER_SASL_STATE_FAIL) { |
c64b22932ffa
Cyrus may not have anything (yet) if it's waiting for a callback or something.
Paul Aurich <paul@darkrain42.org>
parents:
28754
diff
changeset
|
489 if (stanza) { |
c64b22932ffa
Cyrus may not have anything (yet) if it's waiting for a callback or something.
Paul Aurich <paul@darkrain42.org>
parents:
28754
diff
changeset
|
490 jabber_send(js, stanza); |
c64b22932ffa
Cyrus may not have anything (yet) if it's waiting for a callback or something.
Paul Aurich <paul@darkrain42.org>
parents:
28754
diff
changeset
|
491 xmlnode_free(stanza); |
c64b22932ffa
Cyrus may not have anything (yet) if it's waiting for a callback or something.
Paul Aurich <paul@darkrain42.org>
parents:
28754
diff
changeset
|
492 } |
c64b22932ffa
Cyrus may not have anything (yet) if it's waiting for a callback or something.
Paul Aurich <paul@darkrain42.org>
parents:
28754
diff
changeset
|
493 |
22767
d5b3afea8764
After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evan.s@dreskin.net>
parents:
22672
diff
changeset
|
494 return; |
d5b3afea8764
After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evan.s@dreskin.net>
parents:
22672
diff
changeset
|
495 } |
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
|
496 } |
28696
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
497 |
28754
b94fd073187c
jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <paul@darkrain42.org>
parents:
28725
diff
changeset
|
498 if (!msg) |
b94fd073187c
jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <paul@darkrain42.org>
parents:
28725
diff
changeset
|
499 msg = jabber_parse_error(js, packet, &reason); |
b94fd073187c
jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <paul@darkrain42.org>
parents:
28725
diff
changeset
|
500 |
b94fd073187c
jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <paul@darkrain42.org>
parents:
28725
diff
changeset
|
501 if (!msg) { |
27381
f541583e31bd
More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents:
27379
diff
changeset
|
502 purple_connection_error_reason(js->gc, |
21358 | 503 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
27381
f541583e31bd
More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents:
27379
diff
changeset
|
504 _("Invalid response from server")); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
505 } else { |
27381
f541583e31bd
More uniformity among disconnect error messages
Mark Doliner <mark@kingant.net>
parents:
27379
diff
changeset
|
506 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
|
507 g_free(msg); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
508 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
509 } |
28696
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
510 |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
511 static gint compare_mech(gconstpointer a, gconstpointer b) |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
512 { |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
513 const JabberSaslMech *mech_a = a; |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
514 const JabberSaslMech *mech_b = b; |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
515 |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
516 /* higher priority comes *before* lower priority in the list */ |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
517 if (mech_a->priority > mech_b->priority) |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
518 return -1; |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
519 else if (mech_a->priority < mech_b->priority) |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
520 return 1; |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
521 /* This really shouldn't happen */ |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
522 return 0; |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
523 } |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
524 |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
525 void jabber_auth_init(void) |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
526 { |
28707
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
28699
diff
changeset
|
527 JabberSaslMech **tmp; |
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
28699
diff
changeset
|
528 gint count, i; |
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
28699
diff
changeset
|
529 |
28696
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
530 auth_mechs = g_slist_insert_sorted(auth_mechs, jabber_auth_get_plain_mech(), compare_mech); |
28698
f27ed49948b7
jabber: Oops, re-enable DIGEST-MD5 (I was testing PLAIN).
Paul Aurich <paul@darkrain42.org>
parents:
28697
diff
changeset
|
531 auth_mechs = g_slist_insert_sorted(auth_mechs, jabber_auth_get_digest_md5_mech(), compare_mech); |
28696
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
532 #ifdef HAVE_CYRUS_SASL |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
533 auth_mechs = g_slist_insert_sorted(auth_mechs, jabber_auth_get_cyrus_mech(), compare_mech); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
534 #endif |
28707
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
28699
diff
changeset
|
535 |
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
28699
diff
changeset
|
536 tmp = jabber_auth_get_scram_mechs(&count); |
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
28699
diff
changeset
|
537 for (i = 0; i < count; ++i) |
c1d41b7484ff
jabber: Complete (though untested) SCRAM implementation.
Paul Aurich <paul@darkrain42.org>
parents:
28699
diff
changeset
|
538 auth_mechs = g_slist_insert_sorted(auth_mechs, tmp[i], compare_mech); |
28696
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
539 } |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
540 |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
541 void jabber_auth_uninit(void) |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
542 { |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
543 g_slist_free(auth_mechs); |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
544 auth_mechs = NULL; |
8ada06fb65ed
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <paul@darkrain42.org>
parents:
28520
diff
changeset
|
545 } |