annotate libpurple/protocols/msn/nexus.c @ 23461:d756a0477c06

propagate from branch 'im.pidgin.pidgin' (head e1c49c9ec5c6869ed9813feccd8ee41d2ca40f35) to branch 'im.pidgin.pidgin.khc.msnp15' (head cee4156a103d7f7b90a8d4e3a3ebf10950baf0aa)
author Ka-Hing Cheung <khc@hxbc.us>
date Wed, 14 May 2008 04:38:26 +0000
parents f182cf94145c f62a4a7fe365
children 1b98e2090a71
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /**
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 * @file nexus.c MSN Nexus functions
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 *
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
4 * purple
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 *
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
6 * Purple is the legal property of its developers, whose names are too numerous
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 * to list here. Please refer to the COPYRIGHT file distributed with this
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * source distribution.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 * 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
11 * 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
12 * 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
13 * (at your option) any later version.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * 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
16 * 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
17 * 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
18 * GNU General Public License for more details.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 * 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
21 * 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: 19654
diff changeset
22 * 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
23 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24 #include "msn.h"
20530
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20514
diff changeset
25 #include "soap2.h"
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26 #include "nexus.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 #include "notification.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
29
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
30 /**************************************************************************
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
31 * Valid Ticket Tokens
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
32 **************************************************************************/
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
33
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
34 #define SSO_VALID_TICKET_DOMAIN 0
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
35 #define SSO_VALID_TICKET_POLICY 1
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
36 static char *ticket_domains[][2] = {
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
37 /* http://msnpiki.msnfanatic.com/index.php/MSNP15:SSO */
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
38 /* {"Domain", "Policy Ref URI"}, Purpose */
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
39 {"messengerclear.live.com", NULL}, /* Authentication for messenger. */
23452
b268fc2c9121 References #4382, fixes getting offline messages in p15
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23450
diff changeset
40 {"messenger.msn.com", "?id=507"}, /* Authentication for receiving OIMs. */
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
41 {"contacts.msn.com", "MBI"}, /* Authentication for the Contact server. */
23452
b268fc2c9121 References #4382, fixes getting offline messages in p15
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23450
diff changeset
42 {"messengersecure.live.com", "MBI_SSL"}, /* Authentication for sending OIMs. */
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
43 {"spaces.live.com", "MBI"}, /* Authentication for the Windows Live Spaces */
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
44 {"livecontacts.live.com", "MBI"}, /* Live Contacts API, a simplified version of the Contacts SOAP service */
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
45 {"storage.live.com", "MBI"}, /* Storage REST API */
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
46 };
19843
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 16078
diff changeset
47
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48 /**************************************************************************
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 * Main
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 **************************************************************************/
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52 MsnNexus *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 msn_nexus_new(MsnSession *session)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 MsnNexus *nexus;
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
56 int i;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58 nexus = g_new0(MsnNexus, 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59 nexus->session = session;
19843
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 16078
diff changeset
60
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
61 nexus->token_len = sizeof(ticket_domains) / sizeof(char *[2]);
23455
f182cf94145c zero out this, side effect is not crashing when password is incorrect
Ka-Hing Cheung <khc@hxbc.us>
parents: 23453
diff changeset
62 nexus->tokens = g_new0(MsnTicketToken, nexus->token_len);
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
63
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
64 for (i = 0; i < nexus->token_len; i++)
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
65 nexus->tokens[i].token = g_hash_table_new_full(g_str_hash, g_str_equal,
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
66 g_free, g_free);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68 return nexus;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72 msn_nexus_destroy(MsnNexus *nexus)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73 {
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
74 int i;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
75 for (i = 0; i < nexus->token_len; i++) {
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
76 g_hash_table_destroy(nexus->tokens[i].token);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
77 g_free(nexus->tokens[i].secret);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
78 }
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
79
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
80 g_free(nexus->tokens);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
81 g_free(nexus->policy);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
82 g_free(nexus->nonce);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
83 g_free(nexus);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
84 }
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
85
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
86 /**************************************************************************
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
87 * RPS/SSO Authentication
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
88 **************************************************************************/
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
89
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
90 static char *
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
91 sha1_hmac(const char *key, int key_len, const char *message, int msg_len)
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
92 {
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
93 PurpleCipherContext *context;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
94 char *result;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
95 gboolean ret;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
96
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
97 context = purple_cipher_context_new_by_name("hmac", NULL);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
98 purple_cipher_context_set_option(context, "hash", "sha1");
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
99 purple_cipher_context_set_key_with_len(context, (guchar *)key, key_len);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
100
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
101 purple_cipher_context_append(context, (guchar *)message, msg_len);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
102 result = g_malloc(20);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
103 ret = purple_cipher_context_digest(context, 20, (guchar *)result, NULL);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
104
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
105 purple_cipher_context_destroy(context);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
106
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
107 return result;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
108 }
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
109
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
110 static char *
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
111 rps_create_key(const char *key, int key_len, const char *data, size_t data_len)
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
112 {
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
113 char *hash1, *hash2, *hash3, *hash4;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
114 char *result;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
115
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
116 hash1 = sha1_hmac(key, key_len, data, data_len);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
117 hash1 = g_realloc(hash1, 20 + data_len);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
118 memcpy(hash1 + 20, data, data_len);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
119 hash2 = sha1_hmac(key, key_len, hash1, 20 + data_len);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
120
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
121 hash3 = sha1_hmac(key, key_len, hash1, 20);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
122
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
123 hash3 = g_realloc(hash3, 20 + data_len);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
124 memcpy(hash3 + 20, data, data_len);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
125 hash4 = sha1_hmac(key, key_len, hash3, 20 + data_len);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
126
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
127 result = g_malloc(24);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
128 memcpy(result, hash2, 20);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
129 memcpy(result + 20, hash4, 4);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
130
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
131 g_free(hash1);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
132 g_free(hash2);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
133 g_free(hash3);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
134 g_free(hash4);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
135
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
136 return result;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
137 }
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
138
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
139 static char *
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
140 des3_cbc(const char *key, const char *iv, const char *data, int len)
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
141 {
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
142 PurpleCipherContext *des3;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
143 char *out;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
144 size_t outlen;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
146 des3 = purple_cipher_context_new_by_name("des3", NULL);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
147 purple_cipher_context_set_key(des3, (guchar *)key);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
148 purple_cipher_context_set_batch_mode(des3, PURPLE_CIPHER_BATCH_MODE_CBC);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
149 purple_cipher_context_set_iv(des3, (guchar *)iv, 8);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
150
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
151 out = g_malloc(len);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
152 purple_cipher_context_encrypt(des3, (guchar *)data, len, (guchar *)out, &outlen);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
153
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
154 purple_cipher_context_destroy(des3);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
155
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
156 return out;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
157 }
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
158
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
159 #define CRYPT_MODE_CBC 1
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
160 #define CIPHER_TRIPLE_DES 0x6603
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
161 #define HASH_SHA1 0x8004
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
162 static char *
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
163 msn_rps_encrypt(MsnNexus *nexus)
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
164 {
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
165 MsnUsrKey *usr_key;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
166 const char *magic1 = "WS-SecureConversationSESSION KEY HASH";
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
167 const char *magic2 = "WS-SecureConversationSESSION KEY ENCRYPTION";
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
168 size_t len;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
169 char *hash;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
170 char *key1, *key2, *key3;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
171 gsize key1_len;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
172 char *nonce_fixed;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
173 char *cipher;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
174 char *response;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
175
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
176 usr_key = g_malloc(sizeof(MsnUsrKey));
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
177 usr_key->size = GUINT32_TO_LE(28);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
178 usr_key->crypt_mode = GUINT32_TO_LE(CRYPT_MODE_CBC);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
179 usr_key->cipher_type = GUINT32_TO_LE(CIPHER_TRIPLE_DES);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
180 usr_key->hash_type = GUINT32_TO_LE(HASH_SHA1);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
181 usr_key->iv_len = GUINT32_TO_LE(8);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
182 usr_key->hash_len = GUINT32_TO_LE(20);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
183 usr_key->cipher_len = GUINT32_TO_LE(72);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
184
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
185 key1 = (char *)purple_base64_decode((const char *)nexus->tokens[MSN_AUTH_MESSENGER].secret, &key1_len);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
186 len = strlen(magic1);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
187 key2 = rps_create_key(key1, key1_len, magic1, len);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
188 len = strlen(magic2);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
189 key3 = rps_create_key(key1, key1_len, magic2, len);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
190
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
191 usr_key->iv[0] = 0x46; //rand() % 256;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
192 usr_key->iv[1] = 0xC4;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
193 usr_key->iv[2] = 0x14;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
194 usr_key->iv[3] = 0x9F;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
195 usr_key->iv[4] = 0xFF;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
196 usr_key->iv[5] = 0xFC;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
197 usr_key->iv[6] = 0x91;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
198 usr_key->iv[7] = 0x61;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
199
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
200 len = strlen(nexus->nonce);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
201 hash = sha1_hmac(key2, 24, nexus->nonce, len);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
202
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
203 /* We need to pad this to 72 bytes, apparently */
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
204 nonce_fixed = g_malloc(len + 8);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
205 memcpy(nonce_fixed, nexus->nonce, len);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
206 memset(nonce_fixed + len, 0x08, 8);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
207 cipher = des3_cbc(key3, usr_key->iv, nonce_fixed, len + 8);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
208 g_free(nonce_fixed);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
209
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
210 memcpy(usr_key->hash, hash, 20);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
211 memcpy(usr_key->cipher, cipher, 72);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
212
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
213 g_free(key1);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
214 g_free(key2);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
215 g_free(key3);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
216 g_free(hash);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
217 g_free(cipher);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
218
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
219 response = purple_base64_encode((guchar *)usr_key, sizeof(MsnUsrKey));
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
220
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
221 g_free(usr_key);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
222
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
223 return response;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
224 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
225
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
226 /**************************************************************************
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
227 * Login
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228 **************************************************************************/
19843
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 16078
diff changeset
229
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
230 static gboolean
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
231 nexus_parse_response(MsnNexus *nexus, xmlnode *xml)
19843
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 16078
diff changeset
232 {
20530
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20514
diff changeset
233 xmlnode *node;
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
234 gboolean result = FALSE;
20530
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20514
diff changeset
235
23453
bca58b00afab References #4382, replaces usage of msn_soap_xml_get with xmlnode_get_child
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23452
diff changeset
236 node = xmlnode_get_child(xml, "Body/RequestSecurityTokenResponseCollection/RequestSecurityTokenResponse");
20530
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20514
diff changeset
237
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
238 if (node)
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
239 node = node->next; /* The first one is not useful */
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
240 else
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
241 return FALSE;
20530
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20514
diff changeset
242
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20514
diff changeset
243 for (; node; node = node->next) {
23453
bca58b00afab References #4382, replaces usage of msn_soap_xml_get with xmlnode_get_child
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23452
diff changeset
244 xmlnode *token = xmlnode_get_child(node, "RequestedSecurityToken/BinarySecurityToken");
bca58b00afab References #4382, replaces usage of msn_soap_xml_get with xmlnode_get_child
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23452
diff changeset
245 xmlnode *secret = xmlnode_get_child(node, "RequestedProofToken/BinarySecret");
bca58b00afab References #4382, replaces usage of msn_soap_xml_get with xmlnode_get_child
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23452
diff changeset
246 xmlnode *expires = xmlnode_get_child(node, "LifeTime/Expires");
20530
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20514
diff changeset
247
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20514
diff changeset
248 if (token) {
23450
b82a17934604 fixed a memleak or 3, or maybe 4, or 5. Some of these applies to the p14
Ka-Hing Cheung <khc@hxbc.us>
parents: 23447
diff changeset
249 char *token_str, *expiry_str;
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
250 const char *id_str = xmlnode_get_attrib(token, "Id");
20530
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20514
diff changeset
251 char **elems, **cur, **tokens;
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
252 int id;
20530
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20514
diff changeset
253
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
254 if (id_str == NULL) continue;
20530
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20514
diff changeset
255
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
256 id = atol(id_str + 7) - 1; /* 'Compact#' or 'PPToken#' */
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
257 if (id >= nexus->token_len)
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
258 continue; /* Where did this come from? */
20531
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
259
23450
b82a17934604 fixed a memleak or 3, or maybe 4, or 5. Some of these applies to the p14
Ka-Hing Cheung <khc@hxbc.us>
parents: 23447
diff changeset
260 token_str = xmlnode_get_data(token);
20531
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
261 if (token_str == NULL) continue;
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
262 elems = g_strsplit(token_str, "&", 0);
19843
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 16078
diff changeset
263
20530
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20514
diff changeset
264 for (cur = elems; *cur != NULL; cur++){
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20514
diff changeset
265 tokens = g_strsplit(*cur, "=", 2);
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
266 g_hash_table_insert(nexus->tokens[id].token, tokens[0], tokens[1]);
20530
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20514
diff changeset
267 /* Don't free each of the tokens, only the array. */
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20514
diff changeset
268 g_free(tokens);
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20514
diff changeset
269 }
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20514
diff changeset
270
20531
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
271 g_free(token_str);
20530
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20514
diff changeset
272 g_strfreev(elems);
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20514
diff changeset
273
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
274 if (secret)
23450
b82a17934604 fixed a memleak or 3, or maybe 4, or 5. Some of these applies to the p14
Ka-Hing Cheung <khc@hxbc.us>
parents: 23447
diff changeset
275 nexus->tokens[id].secret = xmlnode_get_data(secret);
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
276 else
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
277 nexus->tokens[id].secret = NULL;
20530
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20514
diff changeset
278
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
279 /* Yay for MS using ISO-8601 */
23450
b82a17934604 fixed a memleak or 3, or maybe 4, or 5. Some of these applies to the p14
Ka-Hing Cheung <khc@hxbc.us>
parents: 23447
diff changeset
280 expiry_str = xmlnode_get_data(expires);
20530
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20514
diff changeset
281
23450
b82a17934604 fixed a memleak or 3, or maybe 4, or 5. Some of these applies to the p14
Ka-Hing Cheung <khc@hxbc.us>
parents: 23447
diff changeset
282 nexus->tokens[id].expiry = purple_str_to_time(expiry_str,
b82a17934604 fixed a memleak or 3, or maybe 4, or 5. Some of these applies to the p14
Ka-Hing Cheung <khc@hxbc.us>
parents: 23447
diff changeset
283 FALSE, NULL, NULL, NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
284
23450
b82a17934604 fixed a memleak or 3, or maybe 4, or 5. Some of these applies to the p14
Ka-Hing Cheung <khc@hxbc.us>
parents: 23447
diff changeset
285 g_free(expiry_str);
20530
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20514
diff changeset
286
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
287 purple_debug_info("msnp15", "Updated ticket for domain '%s'\n",
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
288 ticket_domains[id][SSO_VALID_TICKET_DOMAIN]);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
289 result = TRUE;
20530
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20514
diff changeset
290 }
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20514
diff changeset
291 }
20531
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
292
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
293 return result;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
294 }
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
295
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
296 static void
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
297 nexus_got_response_cb(MsnSoapMessage *req, MsnSoapMessage *resp, gpointer data)
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
298 {
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
299 MsnNexus *nexus = data;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
300 MsnSession *session = nexus->session;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
301 char *msn_twn_t, *msn_twn_p, *ticket;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
302 char *response;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
303
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
304 if (resp == NULL) {
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
305 msn_session_set_error(session, MSN_ERROR_SERVCONN, _("Windows Live ID authentication:Unable to connect"));
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
306 return;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
307 }
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
308
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
309 if (!nexus_parse_response(nexus, resp->xml)) {
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
310 msn_session_set_error(session, MSN_ERROR_SERVCONN, _("Windows Live ID authentication:Invalid response"));
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
311 return;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
312 }
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
313
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
314 /*setup the t and p parameter for session*/
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
315 msn_twn_t = g_hash_table_lookup(nexus->tokens[MSN_AUTH_MESSENGER].token, "t");
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
316 msn_twn_p = g_hash_table_lookup(nexus->tokens[MSN_AUTH_MESSENGER].token, "p");
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
317 g_free(session->passport_info.t);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
318 session->passport_info.t = g_strdup(msn_twn_t);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
319 g_free(session->passport_info.p);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
320 session->passport_info.p = g_strdup(msn_twn_p);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
321
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
322 ticket = g_strdup_printf("t=%s&p=%s", msn_twn_t, msn_twn_p);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
323 response = msn_rps_encrypt(nexus);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
324 msn_got_login_params(session, ticket, response);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
325 g_free(ticket);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
326 g_free(response);
19843
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 16078
diff changeset
327 }
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 16078
diff changeset
328
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 16078
diff changeset
329 /*when connect, do the SOAP Style windows Live ID authentication */
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 16078
diff changeset
330 void
20532
10d27a4be2fd removed lots of commented out old soap code
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
331 msn_nexus_connect(MsnNexus *nexus)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
332 {
20530
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20514
diff changeset
333 MsnSession *session = nexus->session;
19843
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 16078
diff changeset
334 char *username, *password;
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
335 GString *domains;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
336 char *request;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
337 int i;
19843
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 16078
diff changeset
338
20530
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20514
diff changeset
339 MsnSoapMessage *soap;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
340
19843
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 16078
diff changeset
341 msn_session_set_login_step(session, MSN_LOGIN_STEP_GET_COOKIE);
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 16078
diff changeset
342
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 16078
diff changeset
343 username = g_strdup(purple_account_get_username(session->account));
21286
b2e646507c18 Use only the first 16 characters of the password, and plug a leak.
Ka-Hing Cheung <khc@hxbc.us>
parents: 21162
diff changeset
344 password = g_strndup(purple_connection_get_password(session->account->gc), 16);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
345
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
346 purple_debug_info("msnp15", "Logging on %s, with policy '%s', nonce '%s'\n",
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
347 username, nexus->policy, nexus->nonce);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
348
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
349 domains = g_string_new(NULL);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
350 for (i = 0; i < nexus->token_len; i++) {
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
351 g_string_append_printf(domains, MSN_SSO_RST_TEMPLATE,
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
352 i+1,
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
353 ticket_domains[i][SSO_VALID_TICKET_DOMAIN],
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
354 ticket_domains[i][SSO_VALID_TICKET_POLICY] != NULL ?
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
355 ticket_domains[i][SSO_VALID_TICKET_POLICY] :
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
356 nexus->policy);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
357 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
358
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
359 request = g_strdup_printf(MSN_SSO_TEMPLATE, username, password, domains->str);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
360 g_free(username);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
361 g_free(password);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
362 g_string_free(domains, TRUE);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
363
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
364 soap = msn_soap_message_new(NULL, xmlnode_from_str(request, -1));
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
365 g_free(request);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
366 msn_soap_message_send(session, soap, MSN_SSO_SERVER, SSO_POST_URL,
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
367 nexus_got_response_cb, nexus);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
368 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
369
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
370 static void
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
371 nexus_got_update_cb(MsnSoapMessage *req, MsnSoapMessage *resp, gpointer data)
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
372 {
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
373 MsnNexus *nexus = data;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
374
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
375 nexus_parse_response(nexus, resp->xml);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
376 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
377
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
378 static void
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
379 msn_nexus_update_token(MsnNexus *nexus, int id)
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
380 {
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
381 MsnSession *session = nexus->session;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
382 char *username, *password;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
383 char *domain;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
384 char *request;
19843
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 16078
diff changeset
385
20530
719ce4acfcb9 the new soap code finally doesn't crash on startup, still can't
Ka-Hing Cheung <khc@hxbc.us>
parents: 20514
diff changeset
386 MsnSoapMessage *soap;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
387
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
388 username = g_strdup(purple_account_get_username(session->account));
21286
b2e646507c18 Use only the first 16 characters of the password, and plug a leak.
Ka-Hing Cheung <khc@hxbc.us>
parents: 21162
diff changeset
389 password = g_strndup(purple_connection_get_password(session->account->gc), 16);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
390
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
391 purple_debug_info("msnp15", "Updating ticket for user '%s' on domain '%s'\n",
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
392 username, ticket_domains[id][SSO_VALID_TICKET_DOMAIN]);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
393
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
394 /* TODO: This really assumes if we send RSTn, the server responds with
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
395 Compactn, even if there is no RST(n-1). This needs checking.
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
396 */
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
397 domain = g_strdup_printf(MSN_SSO_RST_TEMPLATE,
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
398 id,
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
399 ticket_domains[id][SSO_VALID_TICKET_DOMAIN],
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
400 ticket_domains[id][SSO_VALID_TICKET_POLICY] != NULL ?
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
401 ticket_domains[id][SSO_VALID_TICKET_POLICY] :
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
402 nexus->policy);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
403
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
404 request = g_strdup_printf(MSN_SSO_TEMPLATE, username, password, domain);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
405 g_free(username);
21286
b2e646507c18 Use only the first 16 characters of the password, and plug a leak.
Ka-Hing Cheung <khc@hxbc.us>
parents: 21162
diff changeset
406 g_free(password);
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
407 g_free(domain);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
408
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
409 soap = msn_soap_message_new(NULL, xmlnode_from_str(request, -1));
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
410 g_free(request);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
411 msn_soap_message_send(session, soap, MSN_SSO_SERVER, SSO_POST_URL,
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
412 nexus_got_update_cb, nexus);
15373
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
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
415 GHashTable *
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
416 msn_nexus_get_token(MsnNexus *nexus, MsnAuthDomains id)
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
417 {
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
418 g_return_val_if_fail(nexus != NULL, NULL);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
419 g_return_val_if_fail(id < nexus->token_len, NULL);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
420
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
421 if (time(NULL) > nexus->tokens[id].expiry)
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
422 msn_nexus_update_token(nexus, id);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
423
23447
72aa2ccad28d fix sending offline message in p15 by sending the correct token. In msnp14,
Ka-Hing Cheung <khc@hxbc.us>
parents: 23444
diff changeset
424 return nexus->tokens[id].token;
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
425 }
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
426
23447
72aa2ccad28d fix sending offline message in p15 by sending the correct token. In msnp14,
Ka-Hing Cheung <khc@hxbc.us>
parents: 23444
diff changeset
427 const char *
72aa2ccad28d fix sending offline message in p15 by sending the correct token. In msnp14,
Ka-Hing Cheung <khc@hxbc.us>
parents: 23444
diff changeset
428 msn_nexus_get_token_str(MsnNexus *nexus, MsnAuthDomains id)
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
429 {
23447
72aa2ccad28d fix sending offline message in p15 by sending the correct token. In msnp14,
Ka-Hing Cheung <khc@hxbc.us>
parents: 23444
diff changeset
430 static char buf[1024];
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
431 GHashTable *token = msn_nexus_get_token(nexus, id);
23447
72aa2ccad28d fix sending offline message in p15 by sending the correct token. In msnp14,
Ka-Hing Cheung <khc@hxbc.us>
parents: 23444
diff changeset
432 const char *msn_t;
72aa2ccad28d fix sending offline message in p15 by sending the correct token. In msnp14,
Ka-Hing Cheung <khc@hxbc.us>
parents: 23444
diff changeset
433 const char *msn_p;
72aa2ccad28d fix sending offline message in p15 by sending the correct token. In msnp14,
Ka-Hing Cheung <khc@hxbc.us>
parents: 23444
diff changeset
434 gint ret;
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
435
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
436 g_return_val_if_fail(token != NULL, NULL);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
437
23447
72aa2ccad28d fix sending offline message in p15 by sending the correct token. In msnp14,
Ka-Hing Cheung <khc@hxbc.us>
parents: 23444
diff changeset
438 msn_t = g_hash_table_lookup(token, "t");
72aa2ccad28d fix sending offline message in p15 by sending the correct token. In msnp14,
Ka-Hing Cheung <khc@hxbc.us>
parents: 23444
diff changeset
439 msn_p = g_hash_table_lookup(token, "p");
72aa2ccad28d fix sending offline message in p15 by sending the correct token. In msnp14,
Ka-Hing Cheung <khc@hxbc.us>
parents: 23444
diff changeset
440
72aa2ccad28d fix sending offline message in p15 by sending the correct token. In msnp14,
Ka-Hing Cheung <khc@hxbc.us>
parents: 23444
diff changeset
441 g_return_val_if_fail(msn_t != NULL, NULL);
72aa2ccad28d fix sending offline message in p15 by sending the correct token. In msnp14,
Ka-Hing Cheung <khc@hxbc.us>
parents: 23444
diff changeset
442 g_return_val_if_fail(msn_p != NULL, NULL);
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
443
23447
72aa2ccad28d fix sending offline message in p15 by sending the correct token. In msnp14,
Ka-Hing Cheung <khc@hxbc.us>
parents: 23444
diff changeset
444 ret = g_snprintf(buf, sizeof(buf) - 1, "t=%s&amp;p=%s", msn_t, msn_p);
72aa2ccad28d fix sending offline message in p15 by sending the correct token. In msnp14,
Ka-Hing Cheung <khc@hxbc.us>
parents: 23444
diff changeset
445 g_return_val_if_fail(ret != -1, NULL);
72aa2ccad28d fix sending offline message in p15 by sending the correct token. In msnp14,
Ka-Hing Cheung <khc@hxbc.us>
parents: 23444
diff changeset
446
72aa2ccad28d fix sending offline message in p15 by sending the correct token. In msnp14,
Ka-Hing Cheung <khc@hxbc.us>
parents: 23444
diff changeset
447 return buf;
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
448 }
23453
bca58b00afab References #4382, replaces usage of msn_soap_xml_get with xmlnode_get_child
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23452
diff changeset
449