comparison 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
comparison
equal deleted inserted replaced
685:f033345d1315 686:98de2d166a11
430 xmlnode_free(x); 430 xmlnode_free(x);
431 return id; 431 return id;
432 } 432 }
433 433
434 /* 434 /*
435 * jab_auth_mcabber -- authorize user
436 *
437 * parameters
438 * j -- connection
439 * x -- xmlnode iq packet
440 *
441 * returns
442 * non-zero in case of failure
443 */
444 int jab_auth_mcabber(jconn j, xmlnode x)
445 {
446 xmlnode y,z;
447 char *hash, *user;
448
449 if(!j) return -1;
450
451 y = xmlnode_get_tag(x, "query");
452
453 user = j->user->user;
454
455 if (user)
456 {
457 z = xmlnode_insert_tag(y, "username");
458 xmlnode_insert_cdata(z, user, -1);
459 }
460
461 z = xmlnode_insert_tag(y, "resource");
462 xmlnode_insert_cdata(z, j->user->resource, -1);
463
464 if (j->sid)
465 {
466 z = xmlnode_insert_tag(y, "digest");
467 hash = pmalloc(x->p, strlen(j->sid)+strlen(j->pass)+1);
468 strcpy(hash, j->sid);
469 strcat(hash, j->pass);
470 hash = shahash(hash);
471 xmlnode_insert_cdata(z, hash, 40);
472 }
473 else
474 {
475 z = xmlnode_insert_tag(y, "password");
476 xmlnode_insert_cdata(z, j->pass, -1);
477 }
478 return 0;
479 }
480
481 /*
435 * jab_reg -- register user 482 * jab_reg -- register user
436 * 483 *
437 * parameters 484 * parameters
438 * j -- connection 485 * j -- connection
439 * 486 *