Mercurial > hg
diff mcabber/libjabber/jconn.c @ 686:98de2d166a11
Use the new IQ system for authentication
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Mon, 06 Feb 2006 21:06:19 +0100 |
parents | ec86d759ed54 |
children | 40175f3dcef7 |
line wrap: on
line diff
--- a/mcabber/libjabber/jconn.c Mon Feb 06 20:04:58 2006 +0100 +++ b/mcabber/libjabber/jconn.c Mon Feb 06 21:06:19 2006 +0100 @@ -432,6 +432,53 @@ } /* + * jab_auth_mcabber -- authorize user + * + * parameters + * j -- connection + * x -- xmlnode iq packet + * + * returns + * non-zero in case of failure + */ +int jab_auth_mcabber(jconn j, xmlnode x) +{ + xmlnode y,z; + char *hash, *user; + + if(!j) return -1; + + y = xmlnode_get_tag(x, "query"); + + user = j->user->user; + + if (user) + { + z = xmlnode_insert_tag(y, "username"); + xmlnode_insert_cdata(z, user, -1); + } + + z = xmlnode_insert_tag(y, "resource"); + xmlnode_insert_cdata(z, j->user->resource, -1); + + if (j->sid) + { + z = xmlnode_insert_tag(y, "digest"); + hash = pmalloc(x->p, strlen(j->sid)+strlen(j->pass)+1); + strcpy(hash, j->sid); + strcat(hash, j->pass); + hash = shahash(hash); + xmlnode_insert_cdata(z, hash, 40); + } + else + { + z = xmlnode_insert_tag(y, "password"); + xmlnode_insert_cdata(z, j->pass, -1); + } + return 0; +} + +/* * jab_reg -- register user * * parameters