Mercurial > pidgin.yaz
comparison libpurple/protocols/jabber/auth.c @ 31449:1c660ba17ba1
propagate from branch 'im.pidgin.pidgin' (head 6f879669a6513a5c40335bbaefe842389a92b39e)
to branch 'im.pidgin.cpw.qulogic.cairo' (head 4ab0199887f74442673fd46dcbb662bc7f070bc4)
author | Marcus Lundblad <ml@update.uu.se> |
---|---|
date | Sun, 21 Nov 2010 20:30:12 +0000 |
parents | cea7e713ef07 |
children | a5b556ac1de5 |
comparison
equal
deleted
inserted
replaced
31448:9a705087d64e | 31449:1c660ba17ba1 |
---|---|
121 { | 121 { |
122 /* The password prompt dialog doesn't get disposed if the account disconnects */ | 122 /* The password prompt dialog doesn't get disposed if the account disconnects */ |
123 if (!PURPLE_CONNECTION_IS_VALID(gc)) | 123 if (!PURPLE_CONNECTION_IS_VALID(gc)) |
124 return; | 124 return; |
125 | 125 |
126 /* Disable the account as the user has canceled connecting */ | 126 /* Disable the account as the user has cancelled connecting */ |
127 purple_account_set_enabled(purple_connection_get_account(gc), purple_core_get_ui(), FALSE); | 127 purple_account_set_enabled(purple_connection_get_account(gc), purple_core_get_ui(), FALSE); |
128 } | 128 } |
129 #endif | 129 #endif |
130 | 130 |
131 void | 131 void |
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_reason(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 && xmlnode_get_child(query, "digest")) { | 254 if (js->stream_id && *js->stream_id && |
255 xmlnode_get_child(query, "digest")) { | |
255 char *s, *hash; | 256 char *s, *hash; |
256 | 257 |
257 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:auth"); | 258 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:auth"); |
258 query = xmlnode_get_child(iq->node, "query"); | 259 query = xmlnode_get_child(iq->node, "query"); |
259 x = xmlnode_new_child(query, "username"); | 260 x = xmlnode_new_child(query, "username"); |
267 xmlnode_insert_data(x, hash, -1); | 268 xmlnode_insert_data(x, hash, -1); |
268 g_free(hash); | 269 g_free(hash); |
269 g_free(s); | 270 g_free(s); |
270 jabber_iq_set_callback(iq, auth_old_result_cb, NULL); | 271 jabber_iq_set_callback(iq, auth_old_result_cb, NULL); |
271 jabber_iq_send(iq); | 272 jabber_iq_send(iq); |
272 | 273 } else if ((x = xmlnode_get_child(query, "crammd5"))) { |
273 } else if(js->stream_id && (x = xmlnode_get_child(query, "crammd5"))) { | 274 /* For future reference, this appears to be a custom OS X extension |
275 * to non-SASL authentication. | |
276 */ | |
274 const char *challenge; | 277 const char *challenge; |
275 gchar digest[33]; | 278 gchar digest[33]; |
276 PurpleCipherContext *hmac; | 279 PurpleCipherContext *hmac; |
277 | 280 |
278 /* Calculate the MHAC-MD5 digest */ | 281 /* Calculate the MHAC-MD5 digest */ |
338 * We can end up here without encryption if the server doesn't support | 341 * We can end up here without encryption if the server doesn't support |
339 * <stream:features/> and we're not using old-style SSL. If the user | 342 * <stream:features/> and we're not using old-style SSL. If the user |
340 * is requiring SSL/TLS, we need to enforce it. | 343 * is requiring SSL/TLS, we need to enforce it. |
341 */ | 344 */ |
342 if (!jabber_stream_is_ssl(js) && | 345 if (!jabber_stream_is_ssl(js) && |
343 purple_account_get_bool(account, "require_tls", JABBER_DEFAULT_REQUIRE_TLS)) { | 346 g_str_equal("require_tls", |
347 purple_account_get_string(account, "connection_security", JABBER_DEFAULT_REQUIRE_TLS))) { | |
344 purple_connection_error_reason(js->gc, | 348 purple_connection_error_reason(js->gc, |
345 PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR, | 349 PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR, |
346 _("You require encryption, but it is not available on this server.")); | 350 _("You require encryption, but it is not available on this server.")); |
347 return; | 351 return; |
348 } | 352 } |
496 return 1; | 500 return 1; |
497 /* This really shouldn't happen */ | 501 /* This really shouldn't happen */ |
498 return 0; | 502 return 0; |
499 } | 503 } |
500 | 504 |
505 void jabber_auth_add_mech(JabberSaslMech *mech) | |
506 { | |
507 auth_mechs = g_slist_insert_sorted(auth_mechs, mech, compare_mech); | |
508 } | |
509 | |
510 void jabber_auth_remove_mech(JabberSaslMech *mech) | |
511 { | |
512 auth_mechs = g_slist_remove(auth_mechs, mech); | |
513 } | |
514 | |
501 void jabber_auth_init(void) | 515 void jabber_auth_init(void) |
502 { | 516 { |
503 JabberSaslMech **tmp; | 517 JabberSaslMech **tmp; |
504 gint count, i; | 518 gint count, i; |
505 | 519 |
506 auth_mechs = g_slist_insert_sorted(auth_mechs, jabber_auth_get_plain_mech(), compare_mech); | 520 jabber_auth_add_mech(jabber_auth_get_plain_mech()); |
507 auth_mechs = g_slist_insert_sorted(auth_mechs, jabber_auth_get_digest_md5_mech(), compare_mech); | 521 jabber_auth_add_mech(jabber_auth_get_digest_md5_mech()); |
508 #ifdef HAVE_CYRUS_SASL | 522 #ifdef HAVE_CYRUS_SASL |
509 auth_mechs = g_slist_insert_sorted(auth_mechs, jabber_auth_get_cyrus_mech(), compare_mech); | 523 jabber_auth_add_mech(jabber_auth_get_cyrus_mech()); |
510 #endif | 524 #endif |
511 | 525 |
512 tmp = jabber_auth_get_scram_mechs(&count); | 526 tmp = jabber_auth_get_scram_mechs(&count); |
513 for (i = 0; i < count; ++i) | 527 for (i = 0; i < count; ++i) |
514 auth_mechs = g_slist_insert_sorted(auth_mechs, tmp[i], compare_mech); | 528 jabber_auth_add_mech(tmp[i]); |
515 } | 529 } |
516 | 530 |
517 void jabber_auth_uninit(void) | 531 void jabber_auth_uninit(void) |
518 { | 532 { |
519 g_slist_free(auth_mechs); | 533 g_slist_free(auth_mechs); |