Sun, 28 Jun 2009 06:21:28 +0000
Silence some warnings from gcc on OS X. None of these were actually valid.
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
1 | /* |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
2 | * Purple's oscar protocol plugin |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
3 | * This file is the legal property of its developers. |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
4 | * Please see the AUTHORS file distributed alongside this file. |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
5 | * |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
6 | * This library is free software; you can redistribute it and/or |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
7 | * modify it under the terms of the GNU Lesser General Public |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
8 | * License as published by the Free Software Foundation; either |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
9 | * version 2 of the License, or (at your option) any later version. |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
10 | * |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
11 | * This library is distributed in the hope that it will be useful, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
14 | * Lesser General Public License for more details. |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
15 | * |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
16 | * You should have received a copy of the GNU Lesser General Public |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
17 | * License along with this library; if not, write to the Free Software |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
19 | */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
20 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
21 | /** |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
22 | * This file implements AIM's clientLogin procedure for authenticating |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
23 | * users. This replaces the older MD5-based and XOR-based |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
24 | * authentication methods that use SNAC family 0x0017. |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
25 | * |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
26 | * This doesn't use SNACs or FLAPs at all. It makes http and https |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
27 | * POSTs to AOL to validate the user based on the password they |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
28 | * provided to us. Upon successful authentication we request a |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
29 | * connection to the BOS server by calling startOSCARsession. The |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
30 | * AOL server gives us the hostname and port number to use, as well |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
31 | * as the cookie to use to authenticate to the BOS server. And then |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
32 | * everything else is the same as with BUCP. |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
33 | * |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
34 | * For details, see: |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
35 | * http://dev.aol.com/aim/oscar/#AUTH |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
36 | * http://dev.aol.com/authentication_for_clients |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
37 | */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
38 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
39 | #include "cipher.h" |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
40 | #include "core.h" |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
41 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
42 | #include "oscar.h" |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
43 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
44 | #define URL_CLIENT_LOGIN "https://api.screenname.aol.com/auth/clientLogin" |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
45 | #define URL_START_OSCAR_SESSION "http://api.oscar.aol.com/aim/startOSCARSession" |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
46 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
47 | /* |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
48 | * Using clientLogin requires a developer ID. This dev ID is owned by |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
49 | * the AIM account "markdoliner" |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
50 | */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
51 | #define CLIENT_KEY "ma15d7JTxbmVG-RP" |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
52 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
53 | /** |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
54 | * This is similar to purple_url_encode() except that it follows |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
55 | * RFC3986 a little more closely by not encoding - . _ and ~ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
56 | * It also uses capital letters as hex characters because capital |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
57 | * letters are required by AOL. The RFC says that capital letters |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
58 | * are a SHOULD and that URLs that use capital letters are |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
59 | * equivalent to URLs that use small letters. |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
60 | * |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
61 | * TODO: Check if purple_url_encode() can be replaced with this |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
62 | * version without breaking anything. |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
63 | */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
64 | static const char *oscar_auth_url_encode(const char *str) |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
65 | { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
66 | const char *iter; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
67 | static char buf[BUF_LEN]; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
68 | char utf_char[6]; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
69 | guint i, j = 0; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
70 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
71 | g_return_val_if_fail(str != NULL, NULL); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
72 | g_return_val_if_fail(g_utf8_validate(str, -1, NULL), NULL); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
73 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
74 | iter = str; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
75 | for (; *iter && j < (BUF_LEN - 1) ; iter = g_utf8_next_char(iter)) { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
76 | gunichar c = g_utf8_get_char(iter); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
77 | /* If the character is an ASCII character and is alphanumeric |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
78 | * no need to escape */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
79 | if ((c < 128 && isalnum(c)) || c =='-' || c == '.' || c == '_' || c == '~') { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
80 | buf[j++] = c; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
81 | } else { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
82 | int bytes = g_unichar_to_utf8(c, utf_char); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
83 | for (i = 0; i < bytes; i++) { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
84 | if (j > (BUF_LEN - 4)) |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
85 | break; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
86 | sprintf(buf + j, "%%%02X", utf_char[i] & 0xff); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
87 | j += 3; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
88 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
89 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
90 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
91 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
92 | buf[j] = '\0'; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
93 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
94 | return buf; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
95 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
96 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
97 | /** |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
98 | * @return A null-terminated base64 encoded version of the HMAC |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
99 | * calculated using the given key and data. |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
100 | */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
101 | static gchar *hmac_sha256(const char *key, const char *message) |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
102 | { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
103 | PurpleCipherContext *context; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
104 | guchar digest[32]; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
105 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
106 | context = purple_cipher_context_new_by_name("hmac", NULL); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
107 | purple_cipher_context_set_option(context, "hash", "sha256"); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
108 | purple_cipher_context_set_key(context, (guchar *)key); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
109 | purple_cipher_context_append(context, (guchar *)message, strlen(message)); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
110 | purple_cipher_context_digest(context, sizeof(digest), digest, NULL); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
111 | purple_cipher_context_destroy(context); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
112 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
113 | return purple_base64_encode(digest, sizeof(digest)); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
114 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
115 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
116 | /** |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
117 | * @return A base-64 encoded HMAC-SHA256 signature created using the |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
118 | * technique documented at |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
119 | * http://dev.aol.com/authentication_for_clients#signing |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
120 | */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
121 | static gchar *generate_signature(const char *method, const char *url, const char *parameters, const char *session_key) |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
122 | { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
123 | char *encoded_url, *signature_base_string, *signature; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
124 | const char *encoded_parameters; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
125 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
126 | encoded_url = g_strdup(oscar_auth_url_encode(url)); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
127 | encoded_parameters = oscar_auth_url_encode(parameters); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
128 | signature_base_string = g_strdup_printf("%s&%s&%s", |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
129 | method, encoded_url, encoded_parameters); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
130 | g_free(encoded_url); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
131 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
132 | signature = hmac_sha256(session_key, signature_base_string); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
133 | g_free(signature_base_string); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
134 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
135 | return signature; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
136 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
137 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
138 | static gboolean parse_start_oscar_session_response(PurpleConnection *gc, const gchar *response, gsize response_len, char **host, unsigned short *port, char **cookie) |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
139 | { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
140 | xmlnode *response_node, *tmp_node, *data_node; |
|
27442
754d246cd697
Silence some warnings from gcc on OS X. None of these were actually valid.
Paul Aurich <darkrain42@pidgin.im>
parents:
27414
diff
changeset
|
141 | xmlnode *host_node = NULL, *port_node = NULL, *cookie_node = NULL; |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
142 | char *tmp; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
143 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
144 | /* Parse the response as XML */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
145 | response_node = xmlnode_from_str(response, response_len); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
146 | if (response_node == NULL) |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
147 | { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
148 | purple_debug_error("oscar", "startOSCARSession could not parse " |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
149 | "response as XML: %s\n", response); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
150 | purple_connection_error_reason(gc, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
151 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
152 | _("Received unexpected response from " URL_START_OSCAR_SESSION)); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
153 | return FALSE; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
154 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
155 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
156 | /* Grab the necessary XML nodes */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
157 | tmp_node = xmlnode_get_child(response_node, "statusCode"); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
158 | data_node = xmlnode_get_child(response_node, "data"); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
159 | if (data_node != NULL) { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
160 | host_node = xmlnode_get_child(data_node, "host"); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
161 | port_node = xmlnode_get_child(data_node, "port"); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
162 | cookie_node = xmlnode_get_child(data_node, "cookie"); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
163 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
164 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
165 | /* Make sure we have a status code */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
166 | if (tmp_node == NULL || (tmp = xmlnode_get_data_unescaped(tmp_node)) == NULL) { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
167 | purple_debug_error("oscar", "startOSCARSession response was " |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
168 | "missing statusCode: %s\n", response); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
169 | purple_connection_error_reason(gc, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
170 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
171 | _("Received unexpected response from " URL_START_OSCAR_SESSION)); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
172 | xmlnode_free(response_node); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
173 | return FALSE; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
174 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
175 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
176 | /* Make sure the status code was 200 */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
177 | if (strcmp(tmp, "200") != 0) |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
178 | { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
179 | purple_debug_error("oscar", "startOSCARSession response statusCode " |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
180 | "was %s: %s\n", tmp, response); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
181 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
182 | if (strcmp(tmp, "401") == 0) |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
183 | purple_connection_error_reason(gc, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
184 | PURPLE_CONNECTION_ERROR_OTHER_ERROR, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
185 | _("You have been connecting and disconnecting too " |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
186 | "frequently. Wait ten minutes and try again. If " |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
187 | "you continue to try, you will need to wait even " |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
188 | "longer.")); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
189 | else |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
190 | purple_connection_error_reason(gc, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
191 | PURPLE_CONNECTION_ERROR_OTHER_ERROR, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
192 | _("Received unexpected response from " URL_START_OSCAR_SESSION)); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
193 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
194 | g_free(tmp); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
195 | xmlnode_free(response_node); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
196 | return FALSE; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
197 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
198 | g_free(tmp); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
199 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
200 | /* Make sure we have everything else */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
201 | if (data_node == NULL || host_node == NULL || |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
202 | port_node == NULL || cookie_node == NULL) |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
203 | { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
204 | purple_debug_error("oscar", "startOSCARSession response was missing " |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
205 | "something: %s\n", response); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
206 | purple_connection_error_reason(gc, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
207 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
208 | _("Received unexpected response from " URL_START_OSCAR_SESSION)); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
209 | xmlnode_free(response_node); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
210 | return FALSE; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
211 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
212 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
213 | /* Extract data from the XML */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
214 | *host = xmlnode_get_data_unescaped(host_node); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
215 | tmp = xmlnode_get_data_unescaped(port_node); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
216 | *cookie = xmlnode_get_data_unescaped(cookie_node); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
217 | if (*host == NULL || **host == '\0' || tmp == NULL || *tmp == '\0' || cookie == NULL || *cookie == '\0') |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
218 | { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
219 | purple_debug_error("oscar", "startOSCARSession response was missing " |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
220 | "something: %s\n", response); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
221 | purple_connection_error_reason(gc, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
222 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
223 | _("Received unexpected response from " URL_START_OSCAR_SESSION)); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
224 | g_free(*host); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
225 | g_free(tmp); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
226 | g_free(*cookie); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
227 | xmlnode_free(response_node); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
228 | return FALSE; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
229 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
230 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
231 | *port = atoi(tmp); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
232 | g_free(tmp); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
233 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
234 | return TRUE; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
235 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
236 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
237 | static void start_oscar_session_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, const gchar *url_text, gsize len, const gchar *error_message) |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
238 | { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
239 | OscarData *od; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
240 | PurpleConnection *gc; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
241 | char *host, *cookie; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
242 | unsigned short port; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
243 | guint8 *cookiedata; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
244 | gsize cookiedata_len; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
245 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
246 | od = user_data; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
247 | gc = od->gc; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
248 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
249 | od->url_data = NULL; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
250 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
251 | if (error_message != NULL || len == 0) { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
252 | gchar *tmp; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
253 | tmp = g_strdup_printf(_("Error requesting " URL_START_OSCAR_SESSION |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
254 | ": %s"), error_message); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
255 | purple_connection_error_reason(gc, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
256 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
257 | g_free(tmp); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
258 | return; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
259 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
260 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
261 | if (!parse_start_oscar_session_response(gc, url_text, len, &host, &port, &cookie)) |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
262 | return; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
263 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
264 | cookiedata = purple_base64_decode(cookie, &cookiedata_len); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
265 | oscar_connect_to_bos(gc, od, host, port, cookiedata, cookiedata_len); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
266 | g_free(cookiedata); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
267 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
268 | g_free(host); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
269 | g_free(cookie); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
270 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
271 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
272 | static void send_start_oscar_session(OscarData *od, const char *token, const char *session_key, time_t hosttime) |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
273 | { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
274 | char *query_string, *signature, *url; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
275 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
276 | /* Construct the GET parameters */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
277 | query_string = g_strdup_printf("a=%s" |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
278 | "&f=xml" |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
279 | "&k=" CLIENT_KEY |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
280 | "&ts=%zu" |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
281 | "&useTLS=0", |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
282 | oscar_auth_url_encode(token), hosttime); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
283 | signature = generate_signature("GET", URL_START_OSCAR_SESSION, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
284 | query_string, session_key); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
285 | url = g_strdup_printf(URL_START_OSCAR_SESSION "?%s&sig_sha256=%s", |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
286 | query_string, signature); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
287 | g_free(query_string); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
288 | g_free(signature); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
289 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
290 | /* Make the request */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
291 | od->url_data = purple_util_fetch_url(url, TRUE, NULL, FALSE, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
292 | start_oscar_session_cb, od); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
293 | g_free(url); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
294 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
295 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
296 | /** |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
297 | * This function parses the given response from a clientLogin request |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
298 | * and extracts the useful information. |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
299 | * |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
300 | * @param gc The PurpleConnection. If the response data does |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
301 | * not indicate then purple_connection_error_reason() |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
302 | * will be called to close this connection. |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
303 | * @param response The response data from the clientLogin request. |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
304 | * @param response_len The length of the above response, or -1 if |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
305 | * @response is NUL terminated. |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
306 | * @param token If parsing was successful then this will be set to |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
307 | * a newly allocated string containing the token. The |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
308 | * caller should g_free this string when it is finished |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
309 | * with it. On failure this value will be untouched. |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
310 | * @param secret If parsing was successful then this will be set to |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
311 | * a newly allocated string containing the secret. The |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
312 | * caller should g_free this string when it is finished |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
313 | * with it. On failure this value will be untouched. |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
314 | * @param hosttime If parsing was successful then this will be set to |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
315 | * the time on the OpenAuth Server in seconds since the |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
316 | * Unix epoch. On failure this value will be untouched. |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
317 | * |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
318 | * @return TRUE if the request was successful and we were able to |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
319 | * extract all info we need. Otherwise FALSE. |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
320 | */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
321 | static gboolean parse_client_login_response(PurpleConnection *gc, const gchar *response, gsize response_len, char **token, char **secret, time_t *hosttime) |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
322 | { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
323 | xmlnode *response_node, *tmp_node, *data_node; |
|
27442
754d246cd697
Silence some warnings from gcc on OS X. None of these were actually valid.
Paul Aurich <darkrain42@pidgin.im>
parents:
27414
diff
changeset
|
324 | xmlnode *secret_node = NULL, *hosttime_node = NULL, *token_node = NULL, *tokena_node = NULL; |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
325 | char *tmp; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
326 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
327 | /* Parse the response as XML */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
328 | response_node = xmlnode_from_str(response, response_len); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
329 | if (response_node == NULL) |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
330 | { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
331 | purple_debug_error("oscar", "clientLogin could not parse " |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
332 | "response as XML: %s\n", response); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
333 | purple_connection_error_reason(gc, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
334 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
335 | _("Received unexpected response from " URL_CLIENT_LOGIN)); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
336 | return FALSE; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
337 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
338 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
339 | /* Grab the necessary XML nodes */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
340 | tmp_node = xmlnode_get_child(response_node, "statusCode"); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
341 | data_node = xmlnode_get_child(response_node, "data"); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
342 | if (data_node != NULL) { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
343 | secret_node = xmlnode_get_child(data_node, "sessionSecret"); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
344 | hosttime_node = xmlnode_get_child(data_node, "hostTime"); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
345 | token_node = xmlnode_get_child(data_node, "token"); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
346 | if (token_node != NULL) |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
347 | tokena_node = xmlnode_get_child(token_node, "a"); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
348 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
349 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
350 | /* Make sure we have a status code */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
351 | if (tmp_node == NULL || (tmp = xmlnode_get_data_unescaped(tmp_node)) == NULL) { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
352 | purple_debug_error("oscar", "clientLogin response was " |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
353 | "missing statusCode: %s\n", response); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
354 | purple_connection_error_reason(gc, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
355 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
356 | _("Received unexpected response from " URL_CLIENT_LOGIN)); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
357 | xmlnode_free(response_node); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
358 | return FALSE; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
359 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
360 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
361 | /* Make sure the status code was 200 */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
362 | if (strcmp(tmp, "200") != 0) |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
363 | { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
364 | int status_code, status_detail_code = 0; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
365 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
366 | status_code = atoi(tmp); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
367 | g_free(tmp); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
368 | tmp_node = xmlnode_get_child(response_node, "statusDetailCode"); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
369 | if (tmp_node != NULL && (tmp = xmlnode_get_data_unescaped(tmp_node)) != NULL) { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
370 | status_detail_code = atoi(tmp); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
371 | g_free(tmp); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
372 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
373 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
374 | purple_debug_error("oscar", "clientLogin response statusCode " |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
375 | "was %d (%d): %s\n", status_code, status_detail_code, response); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
376 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
377 | if (status_code == 330 && status_detail_code == 3011) { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
378 | purple_connection_error_reason(gc, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
379 | PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
380 | _("Incorrect password.")); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
381 | } else if (status_code == 401 && status_detail_code == 3019) { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
382 | purple_connection_error_reason(gc, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
383 | PURPLE_CONNECTION_ERROR_OTHER_ERROR, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
384 | _("AOL does not allow your screen name to authenticate via this site.")); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
385 | } else |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
386 | purple_connection_error_reason(gc, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
387 | PURPLE_CONNECTION_ERROR_OTHER_ERROR, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
388 | _("Received unexpected response from " URL_CLIENT_LOGIN)); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
389 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
390 | xmlnode_free(response_node); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
391 | return FALSE; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
392 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
393 | g_free(tmp); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
394 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
395 | /* Make sure we have everything else */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
396 | if (data_node == NULL || secret_node == NULL || |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
397 | token_node == NULL || tokena_node == NULL) |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
398 | { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
399 | purple_debug_error("oscar", "clientLogin response was missing " |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
400 | "something: %s\n", response); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
401 | purple_connection_error_reason(gc, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
402 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
403 | _("Received unexpected response from " URL_CLIENT_LOGIN)); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
404 | xmlnode_free(response_node); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
405 | return FALSE; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
406 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
407 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
408 | /* Extract data from the XML */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
409 | *token = xmlnode_get_data_unescaped(tokena_node); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
410 | *secret = xmlnode_get_data_unescaped(secret_node); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
411 | tmp = xmlnode_get_data_unescaped(hosttime_node); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
412 | if (*token == NULL || **token == '\0' || *secret == NULL || **secret == '\0' || tmp == NULL || *tmp == '\0') |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
413 | { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
414 | purple_debug_error("oscar", "clientLogin response was missing " |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
415 | "something: %s\n", response); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
416 | purple_connection_error_reason(gc, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
417 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
418 | _("Received unexpected response from " URL_CLIENT_LOGIN)); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
419 | g_free(*token); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
420 | g_free(*secret); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
421 | g_free(tmp); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
422 | xmlnode_free(response_node); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
423 | return FALSE; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
424 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
425 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
426 | *hosttime = strtol(tmp, NULL, 10); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
427 | g_free(tmp); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
428 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
429 | xmlnode_free(response_node); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
430 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
431 | return TRUE; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
432 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
433 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
434 | static void client_login_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, const gchar *url_text, gsize len, const gchar *error_message) |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
435 | { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
436 | OscarData *od; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
437 | PurpleConnection *gc; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
438 | char *token, *secret, *session_key; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
439 | time_t hosttime; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
440 | int password_len; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
441 | char *password; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
442 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
443 | od = user_data; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
444 | gc = od->gc; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
445 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
446 | od->url_data = NULL; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
447 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
448 | if (error_message != NULL || len == 0) { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
449 | gchar *tmp; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
450 | tmp = g_strdup_printf(_("Error requesting " URL_CLIENT_LOGIN |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
451 | ": %s"), error_message); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
452 | purple_connection_error_reason(gc, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
453 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
454 | g_free(tmp); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
455 | return; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
456 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
457 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
458 | if (!parse_client_login_response(gc, url_text, len, &token, &secret, &hosttime)) |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
459 | return; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
460 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
461 | password_len = strlen(purple_connection_get_password(gc)); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
462 | password = g_strdup_printf("%.*s", |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
463 | od->icq ? MIN(password_len, MAXICQPASSLEN) : password_len, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
464 | purple_connection_get_password(gc)); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
465 | session_key = hmac_sha256(password, secret); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
466 | g_free(password); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
467 | g_free(secret); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
468 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
469 | send_start_oscar_session(od, token, session_key, hosttime); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
470 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
471 | g_free(token); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
472 | g_free(session_key); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
473 | } |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
474 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
475 | /** |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
476 | * This function sends a request to |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
477 | * https://api.screenname.aol.com/auth/clientLogin with the user's |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
478 | * username and password and receives the user's session key, which is |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
479 | * used to request a connection to the BOSS server. |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
480 | */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
481 | void send_client_login(OscarData *od, const char *username) |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
482 | { |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
483 | PurpleConnection *gc; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
484 | GString *request, *body; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
485 | const char *tmp; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
486 | char *password; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
487 | int password_len; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
488 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
489 | gc = od->gc; |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
490 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
491 | /* |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
492 | * We truncate ICQ passwords to 8 characters. There is probably a |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
493 | * limit for AIM passwords, too, but we really only need to do |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
494 | * this for ICQ because older ICQ clients let you enter a password |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
495 | * as long as you wanted and then they truncated it silently. |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
496 | * |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
497 | * And we can truncate based on the number of bytes and not the |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
498 | * number of characters because passwords for AIM and ICQ are |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
499 | * supposed to be plain ASCII (I don't know if this has always been |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
500 | * the case, though). |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
501 | */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
502 | tmp = purple_connection_get_password(gc); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
503 | password_len = strlen(tmp); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
504 | password = g_strndup(tmp, od->icq ? MIN(password_len, MAXICQPASSLEN) : password_len); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
505 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
506 | /* Construct the body of the HTTP POST request */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
507 | body = g_string_new(""); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
508 | g_string_append_printf(body, "devId=" CLIENT_KEY); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
509 | g_string_append_printf(body, "&f=xml"); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
510 | g_string_append_printf(body, "&pwd=%s", oscar_auth_url_encode(password)); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
511 | g_string_append_printf(body, "&s=%s", oscar_auth_url_encode(username)); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
512 | g_free(password); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
513 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
514 | /* Construct an HTTP POST request */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
515 | request = g_string_new("POST /auth/clientLogin HTTP/1.0\r\n" |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
516 | "Connection: close\r\n" |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
517 | "Accept: */*\r\n"); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
518 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
519 | /* Tack on the body */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
520 | g_string_append_printf(request, "Content-Type: application/x-www-form-urlencoded; charset=UTF-8\r\n"); |
|
27414
b676cf2259c7
Dear Compiler, Shut up!
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27385
diff
changeset
|
521 | g_string_append_printf(request, "Content-Length: %" G_GSIZE_FORMAT "\r\n\r\n", body->len); |
|
27385
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
522 | g_string_append_len(request, body->str, body->len); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
523 | g_string_free(body, TRUE); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
524 | |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
525 | /* Send the POST request */ |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
526 | od->url_data = purple_util_fetch_url_request(URL_CLIENT_LOGIN, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
527 | TRUE, NULL, FALSE, request->str, FALSE, |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
528 | client_login_cb, od); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
529 | g_string_free(request, TRUE); |
|
cd0d721fec8f
Check in code that connects to oscar using clientLogin. This is the
Mark Doliner <markdoliner@pidgin.im>
parents:
diff
changeset
|
530 | } |