Blame lasso/id-wsf/interaction_profile_service.c

Packit 228f82
/* $Id$
Packit 228f82
 *
Packit 228f82
 * Lasso - A free implementation of the Liberty Alliance specifications.
Packit 228f82
 *
Packit 228f82
 * Copyright (C) 2004-2007 Entr'ouvert
Packit 228f82
 * http://lasso.entrouvert.org
Packit 228f82
 *
Packit 228f82
 * Authors: See AUTHORS file in top-level directory.
Packit 228f82
 *
Packit 228f82
 * This program is free software; you can redistribute it and/or modify
Packit 228f82
 * it under the terms of the GNU General Public License as published by
Packit 228f82
 * the Free Software Foundation; either version 2 of the License, or
Packit 228f82
 * (at your option) any later version.
Packit 228f82
 *
Packit 228f82
 * This program is distributed in the hope that it will be useful,
Packit 228f82
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 228f82
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 228f82
 * GNU General Public License for more details.
Packit 228f82
 *
Packit 228f82
 * You should have received a copy of the GNU General Public License
Packit 228f82
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
Packit 228f82
 */
Packit 228f82
Packit 228f82
#include "interaction_profile_service.h"
Packit 228f82
#include "../xml/idwsf_strings.h"
Packit 228f82
#include "wsf_profile.h"
Packit 228f82
#include "../xml/soap-1.1/soap_detail.h"
Packit 228f82
#include "../xml/soap-1.1/soap_fault.h"
Packit 228f82
#include "../xml/is_redirect_request.h"
Packit 228f82
#include "../utils.h"
Packit 228f82
Packit 228f82
/**
Packit 228f82
 * SECTION:interaction_profile_service
Packit 228f82
 * @short_description: A service to request user interaction from a principal
Packit 228f82
 * @stability: Unstable
Packit 228f82
 *
Packit 228f82
 */
Packit 228f82
Packit 228f82
Packit 228f82
struct _LassoInteractionProfileServicePrivate
Packit 228f82
{
Packit 228f82
	gboolean dispose_has_run;
Packit 228f82
};
Packit 228f82
Packit 228f82
/*****************************************************************************/
Packit 228f82
/* public methods                                                            */
Packit 228f82
/*****************************************************************************/
Packit 228f82
Packit 228f82
gint
Packit 228f82
lasso_interaction_profile_service_init_request(LassoInteractionProfileService *service)
Packit 228f82
{
Packit 228f82
	LassoWsfProfile *profile;
Packit 228f82
	LassoIsInteractionRequest *request;
Packit 228f82
Packit 228f82
	profile = LASSO_WSF_PROFILE(service);
Packit 228f82
Packit 228f82
	request = lasso_is_interaction_request_new();
Packit 228f82
Packit 228f82
	profile->request = LASSO_NODE(request);
Packit 228f82
Packit 228f82
	return 0;
Packit 228f82
}
Packit 228f82
Packit 228f82
Packit 228f82
gint
Packit 228f82
lasso_interaction_profile_service_process_request_msg(LassoInteractionProfileService *service,
Packit 228f82
		const gchar *msg)
Packit 228f82
{
Packit 228f82
	LassoIsInteractionRequest *request;
Packit 228f82
Packit 228f82
	request = lasso_is_interaction_request_new();
Packit 228f82
	lasso_node_init_from_message((LassoNode*)request, msg);
Packit 228f82
	LASSO_WSF_PROFILE(service)->request = LASSO_NODE(request);
Packit 228f82
Packit 228f82
	return 0;
Packit 228f82
}
Packit 228f82
Packit 228f82
gint
Packit 228f82
lasso_interaction_profile_service_process_response_msg(LassoInteractionProfileService *service,
Packit 228f82
		const gchar *msg)
Packit 228f82
{
Packit 228f82
	LassoIsInteractionResponse *response;
Packit 228f82
Packit 228f82
	response = lasso_is_interaction_response_new();
Packit 228f82
	lasso_node_init_from_message((LassoNode*)response, msg);
Packit 228f82
	LASSO_WSF_PROFILE(service)->response = LASSO_NODE(response);
Packit 228f82
Packit 228f82
	return 0;
Packit 228f82
}
Packit 228f82
Packit 228f82
/**
Packit 228f82
 * lasso_interaction_profile_service_build_redirect_response_msg:
Packit 228f82
 * @profile: a #LassoWsfProfile
Packit 228f82
 * @redirect_url: an #xmlChar string containing an HTTP url for interaction with the user
Packit 228f82
 *
Packit 228f82
 * The redirect_url must contain a way for the interaction service to link this interaction with the
Packit 228f82
 * current request, usually it is the xml:id of the original request.
Packit 228f82
 *
Packit 228f82
 * Return value: 0 if successful, an error code otherwise.
Packit 228f82
 */
Packit 228f82
gint
Packit 228f82
lasso_wsf_profile_init_interaction_service_redirect(LassoWsfProfile *profile, char *redirect_url)
Packit 228f82
{
Packit 228f82
	LassoSoapDetail *detail = NULL;
Packit 228f82
	LassoSoapFault *fault = NULL;
Packit 228f82
Packit 228f82
	lasso_bad_param(WSF_PROFILE, profile);
Packit 228f82
Packit 228f82
	detail = lasso_soap_detail_new();
Packit 228f82
	fault = lasso_soap_fault_new();
Packit 228f82
	lasso_assign_new_gobject(fault->Detail, detail);
Packit 228f82
	lasso_assign_string(fault->faultcode, LASSO_SOAP_FAULT_CODE_SERVER);
Packit 228f82
	lasso_list_add_new_gobject(detail->any, lasso_is_redirect_request_new(redirect_url));
Packit 228f82
Packit 228f82
	return lasso_wsf_profile_init_soap_response(profile, &fault->parent);
Packit 228f82
}
Packit 228f82
Packit 228f82
Packit 228f82
/*****************************************************************************/
Packit 228f82
/* private methods                                                           */
Packit 228f82
/*****************************************************************************/
Packit 228f82
Packit 228f82
static LassoInteractionProfileServiceClass *parent_class = NULL;
Packit 228f82
Packit 228f82
Packit 228f82
/*****************************************************************************/
Packit 228f82
/* instance and class init functions                                         */
Packit 228f82
/*****************************************************************************/
Packit 228f82
Packit 228f82
static void
Packit 228f82
class_init(LassoInteractionProfileServiceClass *klass)
Packit 228f82
{
Packit 228f82
	parent_class = g_type_class_peek_parent(klass);
Packit 228f82
Packit 228f82
}
Packit 228f82
Packit 228f82
GType
Packit 228f82
lasso_interaction_profile_service_get_type()
Packit 228f82
{
Packit 228f82
	static GType this_type = 0;
Packit 228f82
Packit 228f82
	if (!this_type) {
Packit 228f82
		static const GTypeInfo this_info = {
Packit 228f82
			sizeof(LassoInteractionProfileServiceClass),
Packit 228f82
			NULL,
Packit 228f82
			NULL,
Packit 228f82
			(GClassInitFunc) class_init,
Packit 228f82
			NULL,
Packit 228f82
			NULL,
Packit 228f82
			sizeof(LassoInteractionProfileService),
Packit 228f82
			0,
Packit 228f82
			NULL,
Packit 228f82
			NULL
Packit 228f82
		};
Packit 228f82
Packit 228f82
		this_type = g_type_register_static(LASSO_TYPE_WSF_PROFILE,
Packit 228f82
				"LassoInteractionProfileService", &this_info, 0);
Packit 228f82
	}
Packit 228f82
	return this_type;
Packit 228f82
}
Packit 228f82
Packit 228f82
LassoInteractionProfileService*
Packit 228f82
lasso_interaction_profile_service_new(LassoServer *server)
Packit 228f82
{
Packit 228f82
	LassoInteractionProfileService *service = NULL;
Packit 228f82
Packit 228f82
	g_return_val_if_fail(LASSO_IS_SERVER(server), NULL);
Packit 228f82
Packit 228f82
	service = g_object_new(LASSO_TYPE_INTERACTION_PROFILE_SERVICE, NULL);
Packit 228f82
Packit 228f82
	return service;
Packit 228f82
}