1
/* $Id: register_name_identifier_response.c,v 1.16 2004/09/01 09:59:53 fpeters Exp $
3
* Lasso - A free implementation of the Liberty Alliance specifications.
5
* Copyright (C) 2004 Entr'ouvert
6
* http://lasso.entrouvert.org
8
* Authors: Valery Febvre <vfebvre@easter-eggs.com>
9
* Nicolas Clapies <nclapies@entrouvert.com>
11
* This program is free software; you can redistribute it and/or modify
12
* it under the terms of the GNU General Public License as published by
13
* the Free Software Foundation; either version 2 of the License, or
14
* (at your option) any later version.
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU General Public License for more details.
21
* You should have received a copy of the GNU General Public License
22
* along with this program; if not, write to the Free Software
23
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26
#include <lasso/protocols/register_name_identifier_response.h>
28
/*****************************************************************************/
30
/*****************************************************************************/
32
/*****************************************************************************/
34
/*****************************************************************************/
37
lasso_register_name_identifier_response_new_from_query(gchar *query)
43
response = LASSO_NODE(g_object_new(LASSO_TYPE_REGISTER_NAME_IDENTIFIER_RESPONSE, NULL));
45
gd = lasso_query_to_dict(query);
48
lasso_samlp_response_abstract_set_responseID(LASSO_SAMLP_RESPONSE_ABSTRACT(response),
49
lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "ResponseID"), 0));
52
lasso_samlp_response_abstract_set_majorVersion(LASSO_SAMLP_RESPONSE_ABSTRACT(response),
53
lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "MajorVersion"), 0));
56
lasso_samlp_response_abstract_set_minorVersion(LASSO_SAMLP_RESPONSE_ABSTRACT(response),
57
lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "MinorVersion"), 0));
60
lasso_samlp_response_abstract_set_issueInstant(LASSO_SAMLP_RESPONSE_ABSTRACT(response),
61
lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "IssueInstant"), 0));
64
lasso_samlp_response_abstract_set_inResponseTo(LASSO_SAMLP_RESPONSE_ABSTRACT(response),
65
lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "InResponseTo"), 0));
68
lasso_samlp_response_abstract_set_recipient(LASSO_SAMLP_RESPONSE_ABSTRACT(response),
69
lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "Recipient"), 0));
72
lasso_lib_status_response_set_providerID(LASSO_LIB_STATUS_RESPONSE(response),
73
lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "ProviderID"), 0));
76
relayState = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "RelayState"), 0);
77
if (relayState != NULL)
78
lasso_lib_status_response_set_relayState(LASSO_LIB_STATUS_RESPONSE(response), relayState);
80
g_datalist_clear(&gd);
86
lasso_register_name_identifier_response_new_from_soap(gchar *buffer)
89
LassoNode *envelope, *lassoNode_response;
90
xmlNodePtr xmlNode_response;
91
LassoNodeClass *class;
93
response = LASSO_NODE(g_object_new(LASSO_TYPE_REGISTER_NAME_IDENTIFIER_RESPONSE, NULL));
95
envelope = lasso_node_new_from_dump(buffer);
96
lassoNode_response = lasso_node_get_child(envelope, "RegisterNameIdentifierResponse",
99
class = LASSO_NODE_GET_CLASS(lassoNode_response);
100
xmlNode_response = xmlCopyNode(class->get_xmlNode(LASSO_NODE(lassoNode_response)), 1);
101
lasso_node_destroy(lassoNode_response);
103
class = LASSO_NODE_GET_CLASS(response);
104
class->set_xmlNode(LASSO_NODE(response), xmlNode_response);
105
lasso_node_destroy(envelope);
110
/*****************************************************************************/
111
/* instance and class init functions */
112
/*****************************************************************************/
115
lasso_register_name_identifier_response_instance_init(LassoRegisterNameIdentifierResponse *response)
120
lasso_register_name_identifier_response_class_init(LassoRegisterNameIdentifierResponseClass *class)
124
GType lasso_register_name_identifier_response_get_type() {
125
static GType this_type = 0;
128
static const GTypeInfo this_info = {
129
sizeof (LassoRegisterNameIdentifierResponseClass),
132
(GClassInitFunc) lasso_register_name_identifier_response_class_init,
135
sizeof(LassoRegisterNameIdentifierResponse),
137
(GInstanceInitFunc) lasso_register_name_identifier_response_instance_init,
140
this_type = g_type_register_static(LASSO_TYPE_LIB_REGISTER_NAME_IDENTIFIER_RESPONSE,
141
"LassoRegisterNameIdentifierResponse",
148
lasso_register_name_identifier_response_new(gchar *providerID,
149
gchar *statusCodeValue,
152
/* FIXME : change request type */
153
LassoNode *response, *ss, *ssc;
154
xmlChar *inResponseTo, *request_providerID, *request_relayState;
157
response = LASSO_NODE(g_object_new(LASSO_TYPE_REGISTER_NAME_IDENTIFIER_RESPONSE, NULL));
159
/* Set ONLY required elements/attributes */
161
id = lasso_build_unique_id(32);
162
lasso_samlp_response_abstract_set_responseID(LASSO_SAMLP_RESPONSE_ABSTRACT(response),
163
(const xmlChar *)id);
166
lasso_samlp_response_abstract_set_majorVersion(LASSO_SAMLP_RESPONSE_ABSTRACT(response),
167
lassoLibMajorVersion);
169
lasso_samlp_response_abstract_set_minorVersion(LASSO_SAMLP_RESPONSE_ABSTRACT(response),
170
lassoLibMinorVersion);
172
time = lasso_get_current_time();
173
lasso_samlp_response_abstract_set_issueInstant(LASSO_SAMLP_RESPONSE_ABSTRACT(response),
174
(const xmlChar *)time);
177
lasso_lib_status_response_set_providerID(LASSO_LIB_STATUS_RESPONSE(response),
180
inResponseTo = lasso_node_get_attr_value(request, "RequestID", NULL);
181
lasso_samlp_response_abstract_set_inResponseTo(LASSO_SAMLP_RESPONSE_ABSTRACT(response),
183
xmlFree(inResponseTo);
185
request_providerID = lasso_node_get_child_content(request, "ProviderID", NULL, NULL);
186
lasso_samlp_response_abstract_set_recipient(LASSO_SAMLP_RESPONSE_ABSTRACT(response),
188
xmlFree(request_providerID);
190
request_relayState = lasso_node_get_child_content(request, "RelayState", NULL, NULL);
191
if (request_relayState != NULL) {
192
lasso_lib_status_response_set_relayState(LASSO_LIB_STATUS_RESPONSE(response),
194
xmlFree(request_relayState);
197
ss = lasso_samlp_status_new();
198
ssc = lasso_samlp_status_code_new();
199
lasso_samlp_status_code_set_value(LASSO_SAMLP_STATUS_CODE(ssc),
201
lasso_samlp_status_set_statusCode(LASSO_SAMLP_STATUS(ss),
202
LASSO_SAMLP_STATUS_CODE(ssc));
203
lasso_lib_status_response_set_status(LASSO_LIB_STATUS_RESPONSE(response),
204
LASSO_SAMLP_STATUS(ss));
205
lasso_node_destroy(ssc);
206
lasso_node_destroy(ss);
212
lasso_register_name_identifier_response_new_from_request_export(gchar *buffer,
213
lassoNodeExportType export_type,
215
gchar *statusCodeValue)
217
LassoNode *request, *response;
219
g_return_val_if_fail(buffer != NULL, NULL);
221
request = lasso_register_name_identifier_request_new_from_export(buffer, export_type);
224
message(G_LOG_LEVEL_WARNING, "Error while building RegisterNameIdentifierRequest\n");
228
response = lasso_register_name_identifier_response_new(providerID,
236
lasso_register_name_identifier_response_new_from_export(gchar *buffer,
237
lassoNodeExportType export_type)
241
g_return_val_if_fail(buffer != NULL, NULL);
244
case lassoNodeExportTypeQuery:
245
response = lasso_register_name_identifier_response_new_from_query(buffer);
247
case lassoNodeExportTypeSoap:
248
response = lasso_register_name_identifier_response_new_from_soap(buffer);
251
message(G_LOG_LEVEL_WARNING, "Invalid export type\n");