Esempio n. 1
0
static gboolean
sasl_digest_md5_send_initial_response (LmSASL *sasl, GHashTable *challenge)
{
	LmMessage *msg;
	gchar     *response;
	gchar     *response64;
	int        result;

	response = sasl_md5_prepare_response(sasl, challenge);
	if (response == NULL) {
		return FALSE;
	}

	response64 = base64_encode ((gchar *)response, strlen(response));

	msg = lm_message_new (NULL, LM_MESSAGE_TYPE_RESPONSE);
	lm_message_node_set_attributes (msg->node,
					"xmlns", XMPP_NS_SASL_AUTH,
					NULL);
	lm_message_node_set_value (msg->node, response64);

	result = lm_connection_send (sasl->connection, msg, NULL);

	g_free (response);
	g_free (response64);
	lm_message_unref (msg);

	if (!result) {
		return FALSE;
	}

	sasl->state = SASL_AUTH_STATE_DIGEST_MD5_SENT_AUTH_RESPONSE;

	return TRUE;
}
Esempio n. 2
0
static void
parser_text_cb (GMarkupParseContext   *context,
                const gchar           *text,
                gsize                  text_len,
                gpointer               user_data,
                GError               **error)
{
    LmParser *parser;

    g_return_if_fail (user_data != NULL);

    parser = LM_PARSER (user_data);

    if (parser->cur_node && strcmp (text, "") != 0) {
        lm_message_node_set_value (parser->cur_node, text);
    }
}
Esempio n. 3
0
static gboolean
sasl_start (LmSASL *sasl)
{
	LmMessage  *auth_msg;
	gboolean    result;
	const char *mech = NULL;

	auth_msg = lm_message_new (NULL, LM_MESSAGE_TYPE_AUTH);

	if (sasl->auth_type == AUTH_TYPE_PLAIN) {
      		GString *str;
		gchar   *cstr;

		str = g_string_new ("");

		mech = "PLAIN";
		sasl->state = SASL_AUTH_STATE_PLAIN_STARTED;

		if (sasl->username == NULL || sasl->password == NULL) {
			g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SASL,
			       "%s: no username or password provided", 
			       G_STRFUNC);
			if (sasl->handler) {
				sasl->handler (sasl, sasl->connection, FALSE, "no username/password provided");
			}

			return FALSE;
		}

		g_string_append_c (str, '\0');
		g_string_append (str, sasl->username);
		g_string_append_c (str, '\0');
		g_string_append (str, sasl->password);
		cstr = base64_encode ((gchar *)str->str, str->len);

		lm_message_node_set_value (auth_msg->node, cstr);

		g_string_free (str, TRUE);
		g_free (cstr);

		/* Here we say the Google magic word. Bad Google. */
		lm_message_node_set_attributes (auth_msg->node,
						"xmlns:ga", "http://www.google.com/talk/protocol/auth",
						"ga:client-uses-full-bind-result", "true",
						NULL);

	} 
	else if (sasl->auth_type == AUTH_TYPE_DIGEST) {
		mech = "DIGEST-MD5";
		sasl->state = SASL_AUTH_STATE_DIGEST_MD5_STARTED;
	}

	lm_message_node_set_attributes (auth_msg->node,
					"xmlns", XMPP_NS_SASL_AUTH,
					"mechanism", mech,
					NULL);

	result = lm_connection_send (sasl->connection, auth_msg, NULL);
	lm_message_unref (auth_msg);

	if (!result) {
		return FALSE;
	}

	return TRUE;
}