libpurple/protocols/jabber/auth.c

Tue, 01 Dec 2009 07:32:53 +0000

author
Paul Aurich <darkrain42@pidgin.im>
date
Tue, 01 Dec 2009 07:32:53 +0000
branch
cpw.darkrain42.xmpp.scram
changeset 29084
3a821d391ac0
parent 29008
1f288722b5cd
child 29090
b351fcdeede7
permissions
-rw-r--r--

Let's try a more complex set of return states / values for auth mechs.

This won't build with Cyrus support yet.

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

mercurial