changeset 7703:e0e73a26f130

[gaim-migrate @ 8348] ladies and gentlemen, i give you PLAIN auth for SASL committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Tue, 02 Dec 2003 21:18:39 +0000
parents c65759bdd782
children 3d79f9cab273
files ChangeLog src/protocols/jabber/auth.c
diffstat 2 files changed, 18 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Dec 02 17:27:30 2003 +0000
+++ b/ChangeLog	Tue Dec 02 21:18:39 2003 +0000
@@ -3,6 +3,7 @@
 version 0.75cvs :
 	* Yahoo! file transfer (Tim Ringenbach)
 	* Improved i18n support for MSN email notification (Felipe Contreras)
+	* Jabber SASL PLAIN support
 	* Chinese (Simplified) translation updated (Funda Wang)
 	* Chinese (Traditional) translation updated (Ambrose C. Li)
 	* Italian translation updated (Claudio Satriano)
--- a/src/protocols/jabber/auth.c	Tue Dec 02 17:27:30 2003 +0000
+++ b/src/protocols/jabber/auth.c	Tue Dec 02 21:18:39 2003 +0000
@@ -75,25 +75,34 @@
 
 	auth = xmlnode_new("auth");
 	xmlnode_set_attrib(auth, "xmlns", "urn:ietf:params:xml:ns:xmpp-sasl");
+
 	if(digest_md5) {
 		xmlnode_set_attrib(auth, "mechanism", "DIGEST-MD5");
 		js->auth_type = JABBER_AUTH_DIGEST_MD5;
-		/*
 	} else if(plain) {
+		GString *response = g_string_new("");
+		char *enc_out;
+
+		response = g_string_append_len(response, "\0", 1);
+		response = g_string_append(response, js->user->node);
+		response = g_string_append_len(response, "\0", 1);
+		response = g_string_append(response,
+				gaim_account_get_password(js->gc->account));
+
+		enc_out = gaim_base64_encode(response->str, response->len);
+
 		xmlnode_set_attrib(auth, "mechanism", "PLAIN");
-		xmlnode_insert_data(auth, "\0", 1);
-		xmlnode_insert_data(auth, js->user->node, -1);
-		xmlnode_insert_data(auth, "\0", 1);
-		xmlnode_insert_data(auth, gaim_account_get_password(js->gc->account),
-				-1);
+		xmlnode_insert_data(auth, enc_out, -1);
+		g_free(enc_out);
+
 		js->auth_type = JABBER_AUTH_PLAIN;
-		*/
 	} else {
 		gaim_connection_error(js->gc,
 				_("Server does not use any supported authentication method"));
 		xmlnode_free(auth);
 		return;
 	}
+
 	jabber_send(js, auth);
 	xmlnode_free(auth);
 }
@@ -289,9 +298,7 @@
 jabber_auth_handle_challenge(JabberStream *js, xmlnode *packet)
 {
 
-	if(js->auth_type == JABBER_AUTH_PLAIN) {
-		/* XXX: implement me! */
-	} else if(js->auth_type == JABBER_AUTH_DIGEST_MD5) {
+	if(js->auth_type == JABBER_AUTH_DIGEST_MD5) {
 		char *enc_in = xmlnode_get_data(packet);
 		char *dec_in;
 		char *enc_out;