annotate libpurple/protocols/msn/nexus.c @ 32817:6fa0e854cfc6

Add support for reading GNOME3 proxy settings. Patch by Mihai Serban, with some small changes to remove extra variable parameters. committer: Elliott Sales de Andrade <qulogic@pidgin.im>
author mihai.serban@gmail.com
date Sat, 02 Jun 2012 02:27:41 +0000
parents 2851202488e9
children e10e419e6067
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 */
30742
a99b6dcdb60d Remove unnecesary includes from msn.h.
masca@cpw.pidgin.im
parents: 29234
diff changeset
24
30758
230caecf5435 Include internal.h on each c file to avoid windows breakage as recommended by Daniel.
masca@cpw.pidgin.im
parents: 30742
diff changeset
25 #include "internal.h"
30742
a99b6dcdb60d Remove unnecesary includes from msn.h.
masca@cpw.pidgin.im
parents: 29234
diff changeset
26 #include "cipher.h"
a99b6dcdb60d Remove unnecesary includes from msn.h.
masca@cpw.pidgin.im
parents: 29234
diff changeset
27 #include "debug.h"
a99b6dcdb60d Remove unnecesary includes from msn.h.
masca@cpw.pidgin.im
parents: 29234
diff changeset
28
31617
504a65e03514 Remove some struct packing from code that does login. I think this is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30758
diff changeset
29 #include "msnutils.h"
23507
711773577380 Clean up some MSN SOAP stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23493
diff changeset
30 #include "soap.h"
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 #include "nexus.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 #include "notification.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
34 /**************************************************************************
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
35 * Valid Ticket Tokens
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
36 **************************************************************************/
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
37
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
38 #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
39 #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
40 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
41 /* 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
42 /* {"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
43 {"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
44 {"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
45 {"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
46 {"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
47 {"storage.live.com", "MBI"}, /* Storage REST API */
32532
2851202488e9 Pluck service changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31617
diff changeset
48 {"sup.live.com", "MBI"}, /* What's New service */
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
49 };
19843
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 16078
diff changeset
50
15373
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 * Main
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 **************************************************************************/
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 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 msn_nexus_new(MsnSession *session)
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 MsnNexus *nexus;
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
59 int i;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61 nexus = g_new0(MsnNexus, 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62 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
63
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
64 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
65 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
66
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
67 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
68 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
69 g_free, g_free);
15373
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 return nexus;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
74 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75 msn_nexus_destroy(MsnNexus *nexus)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76 {
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
77 int i;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
78 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
79 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
80 g_free(nexus->tokens[i].secret);
25457
3f6dbc414357 Add a missed g_slist_free.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25452
diff changeset
81 g_slist_free(nexus->tokens[i].updates);
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
82 }
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
83
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
84 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
85 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
86 g_free(nexus->nonce);
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
87 g_free(nexus->cipher);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
88 g_free(nexus->secret);
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
89 g_free(nexus);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
90 }
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
91
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 * RPS/SSO Authentication
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
94 **************************************************************************/
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
95
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
96 static char *
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
97 rps_create_key(const char *key, int key_len, const char *data, size_t data_len)
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
98 {
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
99 const guchar magic[] = "WS-SecureConversation";
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
100 const int magic_len = sizeof(magic) - 1;
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
101
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
102 PurpleCipherContext *hmac;
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
103 guchar hash1[20], hash2[20], hash3[20], hash4[20];
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
104 char *result;
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
105
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
106 hmac = purple_cipher_context_new_by_name("hmac", NULL);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
107
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
108 purple_cipher_context_set_option(hmac, "hash", "sha1");
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
109 purple_cipher_context_set_key_with_len(hmac, (guchar *)key, key_len);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
110 purple_cipher_context_append(hmac, magic, magic_len);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
111 purple_cipher_context_append(hmac, (guchar *)data, data_len);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
112 purple_cipher_context_digest(hmac, sizeof(hash1), hash1, NULL);
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
113
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
114 purple_cipher_context_reset(hmac, NULL);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
115 purple_cipher_context_set_option(hmac, "hash", "sha1");
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
116 purple_cipher_context_set_key_with_len(hmac, (guchar *)key, key_len);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
117 purple_cipher_context_append(hmac, hash1, 20);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
118 purple_cipher_context_append(hmac, magic, magic_len);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
119 purple_cipher_context_append(hmac, (guchar *)data, data_len);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
120 purple_cipher_context_digest(hmac, sizeof(hash2), hash2, NULL);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
121
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
122 purple_cipher_context_reset(hmac, NULL);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
123 purple_cipher_context_set_option(hmac, "hash", "sha1");
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
124 purple_cipher_context_set_key_with_len(hmac, (guchar *)key, key_len);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
125 purple_cipher_context_append(hmac, hash1, 20);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
126 purple_cipher_context_digest(hmac, sizeof(hash3), hash3, NULL);
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
127
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
128 purple_cipher_context_reset(hmac, NULL);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
129 purple_cipher_context_set_option(hmac, "hash", "sha1");
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
130 purple_cipher_context_set_key_with_len(hmac, (guchar *)key, key_len);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
131 purple_cipher_context_append(hmac, hash3, sizeof(hash3));
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
132 purple_cipher_context_append(hmac, magic, magic_len);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
133 purple_cipher_context_append(hmac, (guchar *)data, data_len);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
134 purple_cipher_context_digest(hmac, sizeof(hash4), hash4, NULL);
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
135
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
136 purple_cipher_context_destroy(hmac);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
137
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
138 result = g_malloc(24);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
139 memcpy(result, hash2, sizeof(hash2));
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
140 memcpy(result + sizeof(hash2), hash4, 4);
23444
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 return result;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
143 }
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
144
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
145 static char *
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
146 des3_cbc(const char *key, const char *iv, const char *data, int len, gboolean decrypt)
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
147 {
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
148 PurpleCipherContext *des3;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
149 char *out;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
150 size_t outlen;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
151
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
152 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
153 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
154 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
155 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
156
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
157 out = g_malloc(len);
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
158 if (decrypt)
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
159 purple_cipher_context_decrypt(des3, (guchar *)data, len, (guchar *)out, &outlen);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
160 else
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
161 purple_cipher_context_encrypt(des3, (guchar *)data, len, (guchar *)out, &outlen);
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
162
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
163 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
164
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
165 return out;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
166 }
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
167
31617
504a65e03514 Remove some struct packing from code that does login. I think this is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30758
diff changeset
168 #define MSN_USER_KEY_SIZE (7*4 + 8 + 20 + 72)
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
169 #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
170 #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
171 #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
172 static char *
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
173 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
174 {
31617
504a65e03514 Remove some struct packing from code that does login. I think this is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30758
diff changeset
175 char usr_key_base[MSN_USER_KEY_SIZE], *usr_key;
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
176 const char magic1[] = "SESSION KEY HASH";
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
177 const char magic2[] = "SESSION KEY ENCRYPTION";
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
178 PurpleCipherContext *hmac;
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
179 size_t len;
31617
504a65e03514 Remove some struct packing from code that does login. I think this is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30758
diff changeset
180 guchar *hash;
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
181 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
182 gsize key1_len;
31617
504a65e03514 Remove some struct packing from code that does login. I think this is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30758
diff changeset
183 const char *iv;
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
184 char *nonce_fixed;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
185 char *cipher;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
186 char *response;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
187
31617
504a65e03514 Remove some struct packing from code that does login. I think this is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30758
diff changeset
188 usr_key = &usr_key_base[0];
504a65e03514 Remove some struct packing from code that does login. I think this is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30758
diff changeset
189 /* Header */
504a65e03514 Remove some struct packing from code that does login. I think this is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30758
diff changeset
190 msn_push32le(usr_key, 28); /* Header size */
504a65e03514 Remove some struct packing from code that does login. I think this is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30758
diff changeset
191 msn_push32le(usr_key, CRYPT_MODE_CBC); /* Crypt mode */
504a65e03514 Remove some struct packing from code that does login. I think this is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30758
diff changeset
192 msn_push32le(usr_key, CIPHER_TRIPLE_DES); /* Cipher type */
504a65e03514 Remove some struct packing from code that does login. I think this is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30758
diff changeset
193 msn_push32le(usr_key, HASH_SHA1); /* Hash type */
504a65e03514 Remove some struct packing from code that does login. I think this is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30758
diff changeset
194 msn_push32le(usr_key, 8); /* IV size */
504a65e03514 Remove some struct packing from code that does login. I think this is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30758
diff changeset
195 msn_push32le(usr_key, 20); /* Hash size */
504a65e03514 Remove some struct packing from code that does login. I think this is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30758
diff changeset
196 msn_push32le(usr_key, 72); /* Cipher size */
504a65e03514 Remove some struct packing from code that does login. I think this is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30758
diff changeset
197 /* Data */
504a65e03514 Remove some struct packing from code that does login. I think this is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30758
diff changeset
198 iv = usr_key;
504a65e03514 Remove some struct packing from code that does login. I think this is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30758
diff changeset
199 msn_push32le(usr_key, rand());
504a65e03514 Remove some struct packing from code that does login. I think this is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30758
diff changeset
200 msn_push32le(usr_key, rand());
504a65e03514 Remove some struct packing from code that does login. I think this is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30758
diff changeset
201 hash = (guchar *)usr_key;
504a65e03514 Remove some struct packing from code that does login. I think this is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30758
diff changeset
202 usr_key += 20; /* Remaining is cipher data */
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
203
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
204 key1 = (char *)purple_base64_decode((const char *)nexus->tokens[MSN_AUTH_MESSENGER].secret, &key1_len);
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
205 key2 = rps_create_key(key1, key1_len, magic1, sizeof(magic1) - 1);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
206 key3 = rps_create_key(key1, key1_len, magic2, sizeof(magic2) - 1);
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
207
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
208 len = strlen(nexus->nonce);
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
209 hmac = purple_cipher_context_new_by_name("hmac", NULL);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
210 purple_cipher_context_set_option(hmac, "hash", "sha1");
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
211 purple_cipher_context_set_key_with_len(hmac, (guchar *)key2, 24);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
212 purple_cipher_context_append(hmac, (guchar *)nexus->nonce, len);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
213 purple_cipher_context_digest(hmac, 20, hash, NULL);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
214 purple_cipher_context_destroy(hmac);
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
215
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
216 /* 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
217 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
218 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
219 memset(nonce_fixed + len, 0x08, 8);
31617
504a65e03514 Remove some struct packing from code that does login. I think this is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30758
diff changeset
220 cipher = des3_cbc(key3, iv, nonce_fixed, len + 8, FALSE);
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
221 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
222
31617
504a65e03514 Remove some struct packing from code that does login. I think this is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30758
diff changeset
223 memcpy(usr_key, cipher, 72);
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
224
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
225 g_free(key1);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
226 g_free(key2);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
227 g_free(key3);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
228 g_free(cipher);
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
229
31617
504a65e03514 Remove some struct packing from code that does login. I think this is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30758
diff changeset
230 response = purple_base64_encode((guchar *)usr_key_base, MSN_USER_KEY_SIZE);
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
231
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
232 return response;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
233 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
235 /**************************************************************************
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
236 * Login
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
237 **************************************************************************/
19843
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 16078
diff changeset
238
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
239 /* Used to specify which token to update when only doing single updates */
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
240 typedef struct _MsnNexusUpdateData MsnNexusUpdateData;
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
241 struct _MsnNexusUpdateData {
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
242 MsnNexus *nexus;
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
243 int id;
25452
6a0304f317cf I was hoping this wouldn't be necessary, but it seems that the possibility
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24765
diff changeset
244 };
6a0304f317cf I was hoping this wouldn't be necessary, but it seems that the possibility
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24765
diff changeset
245
6a0304f317cf I was hoping this wouldn't be necessary, but it seems that the possibility
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24765
diff changeset
246 typedef struct _MsnNexusUpdateCallback MsnNexusUpdateCallback;
6a0304f317cf I was hoping this wouldn't be necessary, but it seems that the possibility
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24765
diff changeset
247 struct _MsnNexusUpdateCallback {
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
248 GSourceFunc cb;
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
249 gpointer data;
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
250 };
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
251
23476
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
252 static gboolean
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
253 nexus_parse_token(MsnNexus *nexus, int id, xmlnode *node)
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
254 {
23476
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
255 char *token_str, *expiry_str;
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
256 const char *id_str;
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
257 char **elems, **cur, **tokens;
23476
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
258 xmlnode *token = xmlnode_get_child(node, "RequestedSecurityToken/BinarySecurityToken");
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
259 xmlnode *secret = xmlnode_get_child(node, "RequestedProofToken/BinarySecret");
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
260 xmlnode *expires = xmlnode_get_child(node, "LifeTime/Expires");
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
261
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
262 if (!token)
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
263 return FALSE;
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
264
23476
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
265 /* Use the ID that the server sent us */
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
266 if (id == -1) {
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
267 id_str = xmlnode_get_attrib(token, "Id");
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
268 if (id_str == NULL)
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
269 return FALSE;
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
270
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
271 id = atol(id_str + 7) - 1; /* 'Compact#' or 'PPToken#' */
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
272 if (id >= nexus->token_len)
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
273 return FALSE; /* Where did this come from? */
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
274 }
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
275
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
276 token_str = xmlnode_get_data(token);
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
277 if (token_str == NULL)
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
278 return FALSE;
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
279
23493
c5891c8d0c28 Sometimes (after 24h+) when you request a MSN token update, you get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23476
diff changeset
280 g_hash_table_remove_all(nexus->tokens[id].token);
c5891c8d0c28 Sometimes (after 24h+) when you request a MSN token update, you get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23476
diff changeset
281
23476
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
282 elems = g_strsplit(token_str, "&", 0);
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
283
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
284 for (cur = elems; *cur != NULL; cur++) {
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
285 tokens = g_strsplit(*cur, "=", 2);
23476
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
286 g_hash_table_insert(nexus->tokens[id].token, tokens[0], tokens[1]);
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
287 /* Don't free each of the tokens, only the array. */
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
288 g_free(tokens);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
289 }
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
290 g_strfreev(elems);
23476
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
291 g_free(token_str);
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
292
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
293 if (secret)
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
294 nexus->tokens[id].secret = xmlnode_get_data(secret);
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
295 else
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
296 nexus->tokens[id].secret = NULL;
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
297
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
298 /* Yay for MS using ISO-8601 */
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
299 expiry_str = xmlnode_get_data(expires);
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
300 nexus->tokens[id].expiry = purple_str_to_time(expiry_str,
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
301 FALSE, NULL, NULL, NULL);
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
302 g_free(expiry_str);
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
303
23519
7bceac816e19 The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23507
diff changeset
304 purple_debug_info("msn", "Updated ticket for domain '%s', expires at %" G_GINT64_FORMAT ".\n",
23476
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
305 ticket_domains[id][SSO_VALID_TICKET_DOMAIN],
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
306 (gint64)nexus->tokens[id].expiry);
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
307 return TRUE;
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
308 }
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
309
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
310 static gboolean
23493
c5891c8d0c28 Sometimes (after 24h+) when you request a MSN token update, you get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23476
diff changeset
311 nexus_parse_collection(MsnNexus *nexus, int id, xmlnode *collection)
19843
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 16078
diff changeset
312 {
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
313 xmlnode *node;
23476
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
314 gboolean result;
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
315
23493
c5891c8d0c28 Sometimes (after 24h+) when you request a MSN token update, you get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23476
diff changeset
316 node = xmlnode_get_child(collection, "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
317
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
318 if (!node)
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
319 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
320
23493
c5891c8d0c28 Sometimes (after 24h+) when you request a MSN token update, you get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23476
diff changeset
321 result = TRUE;
c5891c8d0c28 Sometimes (after 24h+) when you request a MSN token update, you get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23476
diff changeset
322 for (; node && result; node = node->next) {
c5891c8d0c28 Sometimes (after 24h+) when you request a MSN token update, you get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23476
diff changeset
323 xmlnode *endpoint = xmlnode_get_child(node, "AppliesTo/EndpointReference/Address");
c5891c8d0c28 Sometimes (after 24h+) when you request a MSN token update, you get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23476
diff changeset
324 char *address = xmlnode_get_data(endpoint);
c5891c8d0c28 Sometimes (after 24h+) when you request a MSN token update, you get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23476
diff changeset
325
c5891c8d0c28 Sometimes (after 24h+) when you request a MSN token update, you get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23476
diff changeset
326 if (g_str_equal(address, "http://Passport.NET/tb")) {
c5891c8d0c28 Sometimes (after 24h+) when you request a MSN token update, you get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23476
diff changeset
327 /* This node contains the stuff for updating tokens. */
c5891c8d0c28 Sometimes (after 24h+) when you request a MSN token update, you get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23476
diff changeset
328 char *data;
c5891c8d0c28 Sometimes (after 24h+) when you request a MSN token update, you get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23476
diff changeset
329 xmlnode *cipher = xmlnode_get_child(node, "RequestedSecurityToken/EncryptedData/CipherData/CipherValue");
c5891c8d0c28 Sometimes (after 24h+) when you request a MSN token update, you get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23476
diff changeset
330 xmlnode *secret = xmlnode_get_child(node, "RequestedProofToken/BinarySecret");
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
331
28341
caef0d8dcb04 Leak fix.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25457
diff changeset
332 g_free(nexus->cipher);
23493
c5891c8d0c28 Sometimes (after 24h+) when you request a MSN token update, you get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23476
diff changeset
333 nexus->cipher = xmlnode_get_data(cipher);
c5891c8d0c28 Sometimes (after 24h+) when you request a MSN token update, you get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23476
diff changeset
334 data = xmlnode_get_data(secret);
28341
caef0d8dcb04 Leak fix.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25457
diff changeset
335 g_free(nexus->secret);
23493
c5891c8d0c28 Sometimes (after 24h+) when you request a MSN token update, you get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23476
diff changeset
336 nexus->secret = (char *)purple_base64_decode(data, NULL);
c5891c8d0c28 Sometimes (after 24h+) when you request a MSN token update, you get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23476
diff changeset
337 g_free(data);
c5891c8d0c28 Sometimes (after 24h+) when you request a MSN token update, you get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23476
diff changeset
338
c5891c8d0c28 Sometimes (after 24h+) when you request a MSN token update, you get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23476
diff changeset
339 } else {
c5891c8d0c28 Sometimes (after 24h+) when you request a MSN token update, you get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23476
diff changeset
340 result = nexus_parse_token(nexus, id, node);
c5891c8d0c28 Sometimes (after 24h+) when you request a MSN token update, you get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23476
diff changeset
341 }
c5891c8d0c28 Sometimes (after 24h+) when you request a MSN token update, you get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23476
diff changeset
342 g_free(address);
c5891c8d0c28 Sometimes (after 24h+) when you request a MSN token update, you get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23476
diff changeset
343 }
20531
a96b5015395a signs on!
Ka-Hing Cheung <khc@hxbc.us>
parents: 20530
diff changeset
344
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
345 return result;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
346 }
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
347
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
348 static void
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
349 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
350 {
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
351 MsnNexus *nexus = data;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
352 MsnSession *session = nexus->session;
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
353 const char *ticket;
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
354 char *response;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
355
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
356 if (resp == NULL) {
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
357 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
358 return;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
359 }
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
360
23493
c5891c8d0c28 Sometimes (after 24h+) when you request a MSN token update, you get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23476
diff changeset
361 if (!nexus_parse_collection(nexus, -1,
c5891c8d0c28 Sometimes (after 24h+) when you request a MSN token update, you get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23476
diff changeset
362 xmlnode_get_child(resp->xml,
c5891c8d0c28 Sometimes (after 24h+) when you request a MSN token update, you get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23476
diff changeset
363 "Body/RequestSecurityTokenResponseCollection"))) {
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
364 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
365 return;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
366 }
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
367
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
368 ticket = msn_nexus_get_token_str(nexus, MSN_AUTH_MESSENGER);
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
369 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
370 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
371 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
372 }
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 16078
diff changeset
373
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 16078
diff changeset
374 /*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
375 void
20532
10d27a4be2fd removed lots of commented out old soap code
Ka-Hing Cheung <khc@hxbc.us>
parents: 20531
diff changeset
376 msn_nexus_connect(MsnNexus *nexus)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
377 {
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
378 MsnSession *session = nexus->session;
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
379 const char *username;
23694
019d5ae3ad72 Use MIN(strlen(password), 16) for MSN because g_markup_escape_text will
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23625
diff changeset
380 const char *password;
019d5ae3ad72 Use MIN(strlen(password), 16) for MSN because g_markup_escape_text will
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23625
diff changeset
381 char *password_xml;
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
382 GString *domains;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
383 char *request;
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
384 int i;
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
23519
7bceac816e19 The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23507
diff changeset
388 purple_debug_info("msn", "Starting Windows Live ID authentication\n");
19843
60bc06498746 Committing khc's msnp14 changes from Trac Ticket #148. --rlaager
Ka-Hing Cheung <khc@hxbc.us>
parents: 16078
diff changeset
389 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
390
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
391 username = purple_account_get_username(session->account);
23694
019d5ae3ad72 Use MIN(strlen(password), 16) for MSN because g_markup_escape_text will
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23625
diff changeset
392 password = purple_connection_get_password(session->account->gc);
28500
8464e695c62b Fixes a bad MSN bug where passwords with multi-byte utf8 characters near
Mark Doliner <mark@kingant.net>
parents: 28361
diff changeset
393 if (g_utf8_strlen(password, -1) > 16) {
8464e695c62b Fixes a bad MSN bug where passwords with multi-byte utf8 characters near
Mark Doliner <mark@kingant.net>
parents: 28361
diff changeset
394 /* max byte size for 16 utf8 characters is 64 + 1 for the null */
8464e695c62b Fixes a bad MSN bug where passwords with multi-byte utf8 characters near
Mark Doliner <mark@kingant.net>
parents: 28361
diff changeset
395 gchar truncated[65];
8464e695c62b Fixes a bad MSN bug where passwords with multi-byte utf8 characters near
Mark Doliner <mark@kingant.net>
parents: 28361
diff changeset
396 g_utf8_strncpy(truncated, password, 16);
8464e695c62b Fixes a bad MSN bug where passwords with multi-byte utf8 characters near
Mark Doliner <mark@kingant.net>
parents: 28361
diff changeset
397 password_xml = g_markup_escape_text(truncated, -1);
8464e695c62b Fixes a bad MSN bug where passwords with multi-byte utf8 characters near
Mark Doliner <mark@kingant.net>
parents: 28361
diff changeset
398 } else {
8464e695c62b Fixes a bad MSN bug where passwords with multi-byte utf8 characters near
Mark Doliner <mark@kingant.net>
parents: 28361
diff changeset
399 password_xml = g_markup_escape_text(password, -1);
8464e695c62b Fixes a bad MSN bug where passwords with multi-byte utf8 characters near
Mark Doliner <mark@kingant.net>
parents: 28361
diff changeset
400 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
401
23519
7bceac816e19 The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23507
diff changeset
402 purple_debug_info("msn", "Logging on %s, with policy '%s', nonce '%s'\n",
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
403 username, nexus->policy, nexus->nonce);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
404
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
405 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
406 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
407 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
408 i+1,
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
409 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
410 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
411 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
412 nexus->policy);
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
23694
019d5ae3ad72 Use MIN(strlen(password), 16) for MSN because g_markup_escape_text will
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23625
diff changeset
415 request = g_strdup_printf(MSN_SSO_TEMPLATE, username, password_xml, domains->str);
019d5ae3ad72 Use MIN(strlen(password), 16) for MSN because g_markup_escape_text will
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23625
diff changeset
416 g_free(password_xml);
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
417 g_string_free(domains, TRUE);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
418
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
419 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
420 g_free(request);
23613
860e5e210fc9 Don't print SOAP messages to debug log for "secure" requests. This is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23541
diff changeset
421 msn_soap_message_send(session, soap, MSN_SSO_SERVER, SSO_POST_URL, TRUE,
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
422 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
423 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
424
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
425 static void
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
426 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
427 {
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
428 MsnNexusUpdateData *ud = data;
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
429 MsnNexus *nexus = ud->nexus;
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
430 char iv[8] = {0,0,0,0,0,0,0,0};
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
431 xmlnode *enckey;
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
432 char *tmp;
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
433 char *nonce;
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
434 gsize len;
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
435 char *key;
25452
6a0304f317cf I was hoping this wouldn't be necessary, but it seems that the possibility
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24765
diff changeset
436 GSList *updates;
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
437
23476
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
438 #if 0
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
439 char *decrypted_pp;
23476
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
440 #endif
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
441 char *decrypted_data;
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
442
24765
25667ca518d6 Do something sane if the response is NULL when updating contact tokens,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23694
diff changeset
443 if (resp == NULL)
25667ca518d6 Do something sane if the response is NULL when updating contact tokens,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23694
diff changeset
444 return;
25667ca518d6 Do something sane if the response is NULL when updating contact tokens,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23694
diff changeset
445
23519
7bceac816e19 The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23507
diff changeset
446 purple_debug_info("msn", "Got Update Response for %s.\n", ticket_domains[ud->id][SSO_VALID_TICKET_DOMAIN]);
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
447
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
448 enckey = xmlnode_get_child(resp->xml, "Header/Security/DerivedKeyToken");
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
449 while (enckey) {
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
450 if (g_str_equal(xmlnode_get_attrib(enckey, "Id"), "EncKey"))
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
451 break;
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
452 enckey = xmlnode_get_next_twin(enckey);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
453 }
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
454 if (!enckey) {
23519
7bceac816e19 The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23507
diff changeset
455 purple_debug_error("msn", "Invalid response in token update.\n");
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
456 return;
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
457 }
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
458
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
459 tmp = xmlnode_get_data(xmlnode_get_child(enckey, "Nonce"));
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
460 nonce = (char *)purple_base64_decode(tmp, &len);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
461 key = rps_create_key(nexus->secret, 24, nonce, len);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
462 g_free(tmp);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
463 g_free(nonce);
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
464
23476
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
465 #if 0
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
466 /* Don't know what this is for yet */
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
467 tmp = xmlnode_get_data(xmlnode_get_child(resp->xml,
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
468 "Header/EncryptedPP/EncryptedData/CipherData/CipherValue"));
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
469 if (tmp) {
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
470 decrypted_pp = des3_cbc(key, iv, tmp, len, TRUE);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
471 g_free(tmp);
23519
7bceac816e19 The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23507
diff changeset
472 purple_debug_info("msn", "Got Response Header EncryptedPP: %s\n", decrypted_pp);
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
473 g_free(decrypted_pp);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
474 }
23476
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
475 #endif
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
476
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
477 tmp = xmlnode_get_data(xmlnode_get_child(resp->xml,
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
478 "Body/EncryptedData/CipherData/CipherValue"));
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
479 if (tmp) {
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
480 char *unescaped;
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
481 xmlnode *rstresponse;
23476
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
482
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
483 unescaped = (char *)purple_base64_decode(tmp, &len);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
484 g_free(tmp);
23476
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
485
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
486 decrypted_data = des3_cbc(key, iv, unescaped, len, TRUE);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
487 g_free(unescaped);
23519
7bceac816e19 The great MSN debug message cleanup! Threw in a few whitespace fixes,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23507
diff changeset
488 purple_debug_info("msn", "Got Response Body EncryptedData: %s\n", decrypted_data);
23476
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
489
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
490 rstresponse = xmlnode_from_str(decrypted_data, -1);
23493
c5891c8d0c28 Sometimes (after 24h+) when you request a MSN token update, you get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23476
diff changeset
491 if (g_str_equal(rstresponse->name, "RequestSecurityTokenResponse"))
c5891c8d0c28 Sometimes (after 24h+) when you request a MSN token update, you get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23476
diff changeset
492 nexus_parse_token(nexus, ud->id, rstresponse);
c5891c8d0c28 Sometimes (after 24h+) when you request a MSN token update, you get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23476
diff changeset
493 else
c5891c8d0c28 Sometimes (after 24h+) when you request a MSN token update, you get a
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23476
diff changeset
494 nexus_parse_collection(nexus, ud->id, rstresponse);
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
495 g_free(decrypted_data);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
496 }
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
497
25452
6a0304f317cf I was hoping this wouldn't be necessary, but it seems that the possibility
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24765
diff changeset
498 updates = nexus->tokens[ud->id].updates;
6a0304f317cf I was hoping this wouldn't be necessary, but it seems that the possibility
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24765
diff changeset
499 nexus->tokens[ud->id].updates = NULL;
6a0304f317cf I was hoping this wouldn't be necessary, but it seems that the possibility
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24765
diff changeset
500 while (updates != NULL) {
6a0304f317cf I was hoping this wouldn't be necessary, but it seems that the possibility
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24765
diff changeset
501 MsnNexusUpdateCallback *update = updates->data;
6a0304f317cf I was hoping this wouldn't be necessary, but it seems that the possibility
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24765
diff changeset
502 if (update->cb)
6a0304f317cf I was hoping this wouldn't be necessary, but it seems that the possibility
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24765
diff changeset
503 purple_timeout_add(0, update->cb, update->data);
6a0304f317cf I was hoping this wouldn't be necessary, but it seems that the possibility
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24765
diff changeset
504 g_free(update);
6a0304f317cf I was hoping this wouldn't be necessary, but it seems that the possibility
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24765
diff changeset
505 updates = g_slist_delete_link(updates, updates);
6a0304f317cf I was hoping this wouldn't be necessary, but it seems that the possibility
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24765
diff changeset
506 }
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
507
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
508 g_free(ud);
28361
428d85859b4e Fix a small leak.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 28341
diff changeset
509 g_free(key);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
510 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
511
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
512 void
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
513 msn_nexus_update_token(MsnNexus *nexus, int id, GSourceFunc cb, gpointer data)
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
514 {
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
515 MsnSession *session = nexus->session;
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
516 MsnNexusUpdateData *ud;
25452
6a0304f317cf I was hoping this wouldn't be necessary, but it seems that the possibility
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24765
diff changeset
517 MsnNexusUpdateCallback *update;
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
518 PurpleCipherContext *sha1;
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
519 PurpleCipherContext *hmac;
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
520
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
521 char *key;
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
522
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
523 guchar digest[20];
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
524
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
525 struct tm *tm;
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
526 time_t now;
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
527 char *now_str;
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
528 char *timestamp;
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
529 char *timestamp_b64;
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
530
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
531 char *domain;
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
532 char *domain_b64;
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
533
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
534 char *signedinfo;
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
535 gint32 nonce[6];
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
536 int i;
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
537 char *nonce_b64;
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
538 char *signature_b64;
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
539 guchar signature[20];
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
540
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
541 char *request;
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
542 MsnSoapMessage *soap;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
543
25452
6a0304f317cf I was hoping this wouldn't be necessary, but it seems that the possibility
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24765
diff changeset
544 update = g_new0(MsnNexusUpdateCallback, 1);
6a0304f317cf I was hoping this wouldn't be necessary, but it seems that the possibility
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24765
diff changeset
545 update->cb = cb;
6a0304f317cf I was hoping this wouldn't be necessary, but it seems that the possibility
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24765
diff changeset
546 update->data = data;
6a0304f317cf I was hoping this wouldn't be necessary, but it seems that the possibility
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24765
diff changeset
547
6a0304f317cf I was hoping this wouldn't be necessary, but it seems that the possibility
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24765
diff changeset
548 if (nexus->tokens[id].updates != NULL) {
6a0304f317cf I was hoping this wouldn't be necessary, but it seems that the possibility
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24765
diff changeset
549 /* Update already in progress. Just add to list and return. */
6a0304f317cf I was hoping this wouldn't be necessary, but it seems that the possibility
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24765
diff changeset
550 purple_debug_info("msn",
6a0304f317cf I was hoping this wouldn't be necessary, but it seems that the possibility
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24765
diff changeset
551 "Ticket update for user '%s' on domain '%s' in progress. Adding request to queue.\n",
6a0304f317cf I was hoping this wouldn't be necessary, but it seems that the possibility
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24765
diff changeset
552 purple_account_get_username(session->account),
6a0304f317cf I was hoping this wouldn't be necessary, but it seems that the possibility
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24765
diff changeset
553 ticket_domains[id][SSO_VALID_TICKET_DOMAIN]);
6a0304f317cf I was hoping this wouldn't be necessary, but it seems that the possibility
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24765
diff changeset
554 nexus->tokens[id].updates = g_slist_prepend(nexus->tokens[id].updates,
6a0304f317cf I was hoping this wouldn't be necessary, but it seems that the possibility
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24765
diff changeset
555 update);
6a0304f317cf I was hoping this wouldn't be necessary, but it seems that the possibility
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24765
diff changeset
556 return;
6a0304f317cf I was hoping this wouldn't be necessary, but it seems that the possibility
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24765
diff changeset
557 } else {
6a0304f317cf I was hoping this wouldn't be necessary, but it seems that the possibility
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24765
diff changeset
558 purple_debug_info("msn",
6a0304f317cf I was hoping this wouldn't be necessary, but it seems that the possibility
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24765
diff changeset
559 "Updating ticket for user '%s' on domain '%s'\n",
6a0304f317cf I was hoping this wouldn't be necessary, but it seems that the possibility
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24765
diff changeset
560 purple_account_get_username(session->account),
6a0304f317cf I was hoping this wouldn't be necessary, but it seems that the possibility
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24765
diff changeset
561 ticket_domains[id][SSO_VALID_TICKET_DOMAIN]);
6a0304f317cf I was hoping this wouldn't be necessary, but it seems that the possibility
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24765
diff changeset
562 nexus->tokens[id].updates = g_slist_prepend(nexus->tokens[id].updates,
6a0304f317cf I was hoping this wouldn't be necessary, but it seems that the possibility
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24765
diff changeset
563 update);
6a0304f317cf I was hoping this wouldn't be necessary, but it seems that the possibility
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 24765
diff changeset
564 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
565
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
566 ud = g_new0(MsnNexusUpdateData, 1);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
567 ud->nexus = nexus;
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
568 ud->id = id;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
569
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
570 sha1 = purple_cipher_context_new_by_name("sha1", NULL);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
571
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
572 domain = g_strdup_printf(MSN_SSO_RST_TEMPLATE,
23476
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
573 id,
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
574 ticket_domains[id][SSO_VALID_TICKET_DOMAIN],
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
575 ticket_domains[id][SSO_VALID_TICKET_POLICY] != NULL ?
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
576 ticket_domains[id][SSO_VALID_TICKET_POLICY] :
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
577 nexus->policy);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
578 purple_cipher_context_append(sha1, (guchar *)domain, strlen(domain));
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
579 purple_cipher_context_digest(sha1, 20, digest, NULL);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
580 domain_b64 = purple_base64_encode(digest, 20);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
581
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
582 now = time(NULL);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
583 tm = gmtime(&now);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
584 now_str = g_strdup(purple_utf8_strftime("%Y-%m-%dT%H:%M:%SZ", tm));
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
585 now += 5*60;
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
586 tm = gmtime(&now);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
587 timestamp = g_strdup_printf(MSN_SSO_TIMESTAMP_TEMPLATE,
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
588 now_str,
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
589 purple_utf8_strftime("%Y-%m-%dT%H:%M:%SZ", tm));
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
590 purple_cipher_context_reset(sha1, NULL);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
591 purple_cipher_context_append(sha1, (guchar *)timestamp, strlen(timestamp));
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
592 purple_cipher_context_digest(sha1, 20, digest, NULL);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
593 timestamp_b64 = purple_base64_encode(digest, 20);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
594 g_free(now_str);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
595
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
596 purple_cipher_context_destroy(sha1);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
597
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
598 signedinfo = g_strdup_printf(MSN_SSO_SIGNEDINFO_TEMPLATE,
23476
9fdf0accd4aa Finally got MSN token updating working (I think).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23468
diff changeset
599 id,
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
600 domain_b64,
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
601 timestamp_b64);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
602
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
603 for (i = 0; i < 6; i++)
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
604 nonce[i] = rand();
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
605 nonce_b64 = purple_base64_encode((guchar *)&nonce, sizeof(nonce));
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
606
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
607 key = rps_create_key(nexus->secret, 24, (char *)nonce, sizeof(nonce));
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
608 hmac = purple_cipher_context_new_by_name("hmac", NULL);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
609 purple_cipher_context_set_option(hmac, "hash", "sha1");
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
610 purple_cipher_context_set_key_with_len(hmac, (guchar *)key, 24);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
611 purple_cipher_context_append(hmac, (guchar *)signedinfo, strlen(signedinfo));
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
612 purple_cipher_context_digest(hmac, 20, signature, NULL);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
613 purple_cipher_context_destroy(hmac);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
614 signature_b64 = purple_base64_encode(signature, 20);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
615
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
616 request = g_strdup_printf(MSN_SSO_TOKEN_UPDATE_TEMPLATE,
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
617 nexus->cipher,
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
618 nonce_b64,
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
619 timestamp,
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
620 signedinfo,
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
621 signature_b64,
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
622 domain);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
623
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
624 g_free(nonce_b64);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
625 g_free(domain_b64);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
626 g_free(timestamp_b64);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
627 g_free(timestamp);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
628 g_free(key);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
629 g_free(signature_b64);
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
630 g_free(signedinfo);
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
631 g_free(domain);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
632
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
633 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
634 g_free(request);
23613
860e5e210fc9 Don't print SOAP messages to debug log for "secure" requests. This is
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23541
diff changeset
635 msn_soap_message_send(session, soap, MSN_SSO_SERVER, SSO_POST_URL, TRUE,
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
636 nexus_got_update_cb, ud);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
637 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
638
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
639 GHashTable *
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
640 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
641 {
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
642 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
643 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
644
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
645 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
646 }
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
647
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
648 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
649 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
650 {
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
651 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
652 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
653 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
654 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
655 gint ret;
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
656
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
657 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
658
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
659 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
660 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
661
72aa2ccad28d fix sending offline message in p15 by sending the correct token. In msnp14,
Ka-Hing Cheung <khc@hxbc.us>
parents: 23444
diff changeset
662 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
663 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
664
23468
1b98e2090a71 Update MSN nexus functions so that tokens are properly updateable. It
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23461
diff changeset
665 ret = g_snprintf(buf, sizeof(buf) - 1, "t=%s&p=%s", msn_t, msn_p);
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
666 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
667
72aa2ccad28d fix sending offline message in p15 by sending the correct token. In msnp14,
Ka-Hing Cheung <khc@hxbc.us>
parents: 23444
diff changeset
668 return buf;
23444
25899ec348a4 Patch 2 from Qulogic, this one adds SSO authentication
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 21594
diff changeset
669 }
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
670