Mercurial > pidgin
comparison libpurple/protocols/jabber/auth.c @ 32819:2c6510167895 default tip
propagate from branch 'im.pidgin.pidgin.2.x.y' (head 3315c5dfbd0ad16511bdcf865e5b07c02d07df24)
to branch 'im.pidgin.pidgin' (head cbd1eda6bcbf0565ae7766396bb8f6f419cb6a9a)
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Sat, 02 Jun 2012 02:30:49 +0000 |
parents | a5b556ac1de5 |
children |
comparison
equal
deleted
inserted
replaced
32818:01ff09d4a463 | 32819:2c6510167895 |
---|---|
75 finish_plaintext_authentication(js); | 75 finish_plaintext_authentication(js); |
76 } | 76 } |
77 | 77 |
78 static void disallow_plaintext_auth(PurpleAccount *account) | 78 static void disallow_plaintext_auth(PurpleAccount *account) |
79 { | 79 { |
80 purple_connection_error_reason(purple_account_get_connection(account), | 80 purple_connection_error(purple_account_get_connection(account), |
81 PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR, | 81 PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR, |
82 _("Server requires plaintext authentication over an unencrypted stream")); | 82 _("Server requires plaintext authentication over an unencrypted stream")); |
83 } | 83 } |
84 | 84 |
85 #ifdef HAVE_CYRUS_SASL | 85 #ifdef HAVE_CYRUS_SASL |
143 return; | 143 return; |
144 } | 144 } |
145 | 145 |
146 mechs = xmlnode_get_child(packet, "mechanisms"); | 146 mechs = xmlnode_get_child(packet, "mechanisms"); |
147 if(!mechs) { | 147 if(!mechs) { |
148 purple_connection_error_reason(js->gc, | 148 purple_connection_error(js->gc, |
149 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | 149 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
150 _("Invalid response from server")); | 150 _("Invalid response from server")); |
151 return; | 151 return; |
152 } | 152 } |
153 | 153 |
184 mechanisms = g_slist_delete_link(mechanisms, mechanisms); | 184 mechanisms = g_slist_delete_link(mechanisms, mechanisms); |
185 } | 185 } |
186 | 186 |
187 if (js->auth_mech == NULL) { | 187 if (js->auth_mech == NULL) { |
188 /* Found no good mechanisms... */ | 188 /* Found no good mechanisms... */ |
189 purple_connection_error_reason(js->gc, | 189 purple_connection_error(js->gc, |
190 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, | 190 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, |
191 _("Server does not use any supported authentication method")); | 191 _("Server does not use any supported authentication method")); |
192 return; | 192 return; |
193 } | 193 } |
194 | 194 |
195 state = js->auth_mech->start(js, mechs, &response, &msg); | 195 state = js->auth_mech->start(js, mechs, &response, &msg); |
196 if (state == JABBER_SASL_STATE_FAIL) { | 196 if (state == JABBER_SASL_STATE_FAIL) { |
197 purple_connection_error_reason(js->gc, | 197 purple_connection_error(js->gc, |
198 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, | 198 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, |
199 msg ? msg : _("Unknown Error")); | 199 msg ? msg : _("Unknown Error")); |
200 } else if (response) { | 200 } else if (response) { |
201 jabber_send(js, response); | 201 jabber_send(js, response); |
202 xmlnode_free(response); | 202 xmlnode_free(response); |
229 /* Clear the pasword if it isn't being saved */ | 229 /* Clear the pasword if it isn't being saved */ |
230 if (!purple_account_get_remember_password(account)) | 230 if (!purple_account_get_remember_password(account)) |
231 purple_account_set_password(account, NULL); | 231 purple_account_set_password(account, NULL); |
232 } | 232 } |
233 | 233 |
234 purple_connection_error_reason(js->gc, reason, msg); | 234 purple_connection_error(js->gc, reason, msg); |
235 g_free(msg); | 235 g_free(msg); |
236 } | 236 } |
237 } | 237 } |
238 | 238 |
239 static void auth_old_cb(JabberStream *js, const char *from, | 239 static void auth_old_cb(JabberStream *js, const char *from, |
245 const char *pw = purple_connection_get_password(js->gc); | 245 const char *pw = purple_connection_get_password(js->gc); |
246 | 246 |
247 if (type == JABBER_IQ_ERROR) { | 247 if (type == JABBER_IQ_ERROR) { |
248 PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR; | 248 PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR; |
249 char *msg = jabber_parse_error(js, packet, &reason); | 249 char *msg = jabber_parse_error(js, packet, &reason); |
250 purple_connection_error_reason(js->gc, reason, msg); | 250 purple_connection_error(js->gc, reason, msg); |
251 g_free(msg); | 251 g_free(msg); |
252 } else if (type == JABBER_IQ_RESULT) { | 252 } else if (type == JABBER_IQ_RESULT) { |
253 query = xmlnode_get_child(packet, "query"); | 253 query = xmlnode_get_child(packet, "query"); |
254 if (js->stream_id && *js->stream_id && | 254 if (js->stream_id && *js->stream_id && |
255 xmlnode_get_child(query, "digest")) { | 255 xmlnode_get_child(query, "digest")) { |
319 g_free(msg); | 319 g_free(msg); |
320 return; | 320 return; |
321 } | 321 } |
322 finish_plaintext_authentication(js); | 322 finish_plaintext_authentication(js); |
323 } else { | 323 } else { |
324 purple_connection_error_reason(js->gc, | 324 purple_connection_error(js->gc, |
325 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, | 325 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, |
326 _("Server does not use any supported authentication method")); | 326 _("Server does not use any supported authentication method")); |
327 return; | 327 return; |
328 } | 328 } |
329 } | 329 } |
343 * is requiring SSL/TLS, we need to enforce it. | 343 * is requiring SSL/TLS, we need to enforce it. |
344 */ | 344 */ |
345 if (!jabber_stream_is_ssl(js) && | 345 if (!jabber_stream_is_ssl(js) && |
346 g_str_equal("require_tls", | 346 g_str_equal("require_tls", |
347 purple_account_get_string(account, "connection_security", JABBER_DEFAULT_REQUIRE_TLS))) { | 347 purple_account_get_string(account, "connection_security", JABBER_DEFAULT_REQUIRE_TLS))) { |
348 purple_connection_error_reason(js->gc, | 348 purple_connection_error(js->gc, |
349 PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR, | 349 PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR, |
350 _("You require encryption, but it is not available on this server.")); | 350 _("You require encryption, but it is not available on this server.")); |
351 return; | 351 return; |
352 } | 352 } |
353 | 353 |
392 jabber_auth_handle_challenge(JabberStream *js, xmlnode *packet) | 392 jabber_auth_handle_challenge(JabberStream *js, xmlnode *packet) |
393 { | 393 { |
394 const char *ns = xmlnode_get_namespace(packet); | 394 const char *ns = xmlnode_get_namespace(packet); |
395 | 395 |
396 if (!purple_strequal(ns, NS_XMPP_SASL)) { | 396 if (!purple_strequal(ns, NS_XMPP_SASL)) { |
397 purple_connection_error_reason(js->gc, | 397 purple_connection_error(js->gc, |
398 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | 398 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
399 _("Invalid response from server")); | 399 _("Invalid response from server")); |
400 return; | 400 return; |
401 } | 401 } |
402 | 402 |
403 if (js->auth_mech && js->auth_mech->handle_challenge) { | 403 if (js->auth_mech && js->auth_mech->handle_challenge) { |
404 xmlnode *response = NULL; | 404 xmlnode *response = NULL; |
405 char *msg = NULL; | 405 char *msg = NULL; |
406 JabberSaslState state = js->auth_mech->handle_challenge(js, packet, &response, &msg); | 406 JabberSaslState state = js->auth_mech->handle_challenge(js, packet, &response, &msg); |
407 if (state == JABBER_SASL_STATE_FAIL) { | 407 if (state == JABBER_SASL_STATE_FAIL) { |
408 purple_connection_error_reason(js->gc, | 408 purple_connection_error(js->gc, |
409 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, | 409 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, |
410 msg ? msg : _("Invalid challenge from server")); | 410 msg ? msg : _("Invalid challenge from server")); |
411 } else if (response) { | 411 } else if (response) { |
412 jabber_send(js, response); | 412 jabber_send(js, response); |
413 xmlnode_free(response); | 413 xmlnode_free(response); |
421 void jabber_auth_handle_success(JabberStream *js, xmlnode *packet) | 421 void jabber_auth_handle_success(JabberStream *js, xmlnode *packet) |
422 { | 422 { |
423 const char *ns = xmlnode_get_namespace(packet); | 423 const char *ns = xmlnode_get_namespace(packet); |
424 | 424 |
425 if (!purple_strequal(ns, NS_XMPP_SASL)) { | 425 if (!purple_strequal(ns, NS_XMPP_SASL)) { |
426 purple_connection_error_reason(js->gc, | 426 purple_connection_error(js->gc, |
427 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | 427 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
428 _("Invalid response from server")); | 428 _("Invalid response from server")); |
429 return; | 429 return; |
430 } | 430 } |
431 | 431 |
432 if (js->auth_mech && js->auth_mech->handle_success) { | 432 if (js->auth_mech && js->auth_mech->handle_success) { |
433 char *msg = NULL; | 433 char *msg = NULL; |
434 JabberSaslState state = js->auth_mech->handle_success(js, packet, &msg); | 434 JabberSaslState state = js->auth_mech->handle_success(js, packet, &msg); |
435 | 435 |
436 if (state == JABBER_SASL_STATE_FAIL) { | 436 if (state == JABBER_SASL_STATE_FAIL) { |
437 purple_connection_error_reason(js->gc, | 437 purple_connection_error(js->gc, |
438 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, | 438 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, |
439 msg ? msg : _("Invalid response from server")); | 439 msg ? msg : _("Invalid response from server")); |
440 return; | 440 return; |
441 } else if (state == JABBER_SASL_STATE_CONTINUE) { | 441 } else if (state == JABBER_SASL_STATE_CONTINUE) { |
442 purple_connection_error_reason(js->gc, | 442 purple_connection_error(js->gc, |
443 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, | 443 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, |
444 msg ? msg : _("Server thinks authentication is complete, but client does not")); | 444 msg ? msg : _("Server thinks authentication is complete, but client does not")); |
445 return; | 445 return; |
446 } | 446 } |
447 | 447 |
477 | 477 |
478 if (!msg) | 478 if (!msg) |
479 msg = jabber_parse_error(js, packet, &reason); | 479 msg = jabber_parse_error(js, packet, &reason); |
480 | 480 |
481 if (!msg) { | 481 if (!msg) { |
482 purple_connection_error_reason(js->gc, | 482 purple_connection_error(js->gc, |
483 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | 483 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
484 _("Invalid response from server")); | 484 _("Invalid response from server")); |
485 } else { | 485 } else { |
486 purple_connection_error_reason(js->gc, reason, msg); | 486 purple_connection_error(js->gc, reason, msg); |
487 g_free(msg); | 487 g_free(msg); |
488 } | 488 } |
489 } | 489 } |
490 | 490 |
491 static gint compare_mech(gconstpointer a, gconstpointer b) | 491 static gint compare_mech(gconstpointer a, gconstpointer b) |