2 * Copyright (C) 2008 Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include "xmpp_internal.h"
26 hc_xmpp_sasl_authenticate (hc_xmpp_t *xmpp)
28 const char *mech = "PLAIN";
31 gsasl_client_start (xmpp->sasl_ctx, mech, &xmpp->sasl_session);
32 gsasl_property_set (xmpp->sasl_session, GSASL_AUTHID, xmpp->user);
33 gsasl_property_set (xmpp->sasl_session, GSASL_PASSWORD, xmpp->password);
34 gsasl_step64 (xmpp->sasl_session, p, &p);
35 auth = iks_new ("auth");
36 iks_insert_attrib (auth, "xmlns", HC_XMPP_NS_SASL);
37 iks_insert_attrib (auth, "mechanism", mech);
38 iks_insert_cdata (auth, p, 0);
39 hc_xmpp_send_iks (xmpp, auth);
45 hc_xmpp_sasl_iterate (hc_xmpp_t *xmpp, iks *stanza)
47 if (!iks_strcmp (iks_name (stanza), "success"))
49 xmpp->sasl |= ENABLED;
50 xmpp->status = HC_XMPP_AUTHENTICATED;