1
/* $Id: federation_termination_notification.c,v 1.22 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/federation_termination_notification.h>
27
#include <lasso/xml/saml_name_identifier.h>
29
/*****************************************************************************/
31
/*****************************************************************************/
33
/*****************************************************************************/
34
/* instance and class init functions */
35
/*****************************************************************************/
38
lasso_federation_termination_notification_instance_init(LassoFederationTerminationNotification *request)
43
lasso_federation_termination_notification_class_init(LassoFederationTerminationNotificationClass *class)
47
GType lasso_federation_termination_notification_get_type() {
48
static GType this_type = 0;
51
static const GTypeInfo this_info = {
52
sizeof (LassoFederationTerminationNotificationClass),
55
(GClassInitFunc) lasso_federation_termination_notification_class_init,
58
sizeof(LassoFederationTerminationNotification),
60
(GInstanceInitFunc) lasso_federation_termination_notification_instance_init,
63
this_type = g_type_register_static(LASSO_TYPE_LIB_FEDERATION_TERMINATION_NOTIFICATION,
64
"LassoFederationTerminationNotification",
71
lasso_federation_termination_notification_new(const xmlChar *providerID,
72
const xmlChar *nameIdentifier,
73
const xmlChar *nameQualifier,
74
const xmlChar *format,
75
lassoSignatureType sign_type,
76
lassoSignatureMethod sign_method)
78
LassoNode *request, *identifier;
81
request = LASSO_NODE(g_object_new(LASSO_TYPE_FEDERATION_TERMINATION_NOTIFICATION, NULL));
83
/* Set ONLY required elements/attributes */
85
id = lasso_build_unique_id(32);
86
lasso_samlp_request_abstract_set_requestID(LASSO_SAMLP_REQUEST_ABSTRACT(request),
90
lasso_samlp_request_abstract_set_majorVersion(LASSO_SAMLP_REQUEST_ABSTRACT(request),
91
lassoLibMajorVersion);
93
lasso_samlp_request_abstract_set_minorVersion(LASSO_SAMLP_REQUEST_ABSTRACT(request),
94
lassoLibMinorVersion);
96
time = lasso_get_current_time();
97
lasso_samlp_request_abstract_set_issueInstant(LASSO_SAMLP_REQUEST_ABSTRACT(request),
98
(const xmlChar *)time);
101
/* set the signature template */
102
if (sign_type != lassoSignatureTypeNone) {
103
lasso_samlp_request_abstract_set_signature_tmpl(LASSO_SAMLP_REQUEST_ABSTRACT(request),
110
lasso_lib_federation_termination_notification_set_providerID(LASSO_LIB_FEDERATION_TERMINATION_NOTIFICATION(request),
113
identifier = lasso_saml_name_identifier_new(nameIdentifier);
114
lasso_saml_name_identifier_set_nameQualifier(LASSO_SAML_NAME_IDENTIFIER(identifier), nameQualifier);
115
lasso_saml_name_identifier_set_format(LASSO_SAML_NAME_IDENTIFIER(identifier), format);
117
lasso_lib_federation_termination_notification_set_nameIdentifier(LASSO_LIB_FEDERATION_TERMINATION_NOTIFICATION(request),
118
LASSO_SAML_NAME_IDENTIFIER(identifier));
119
lasso_node_destroy(identifier);
125
lasso_federation_termination_notification_new_from_query(const gchar *query)
127
LassoNode *notification, *identifier;
131
notification = LASSO_NODE(g_object_new(LASSO_TYPE_FEDERATION_TERMINATION_NOTIFICATION, NULL));
133
gd = lasso_query_to_dict(query);
135
g_object_unref(notification);
140
str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "RequestID"), 0);
142
g_datalist_clear(&gd);
143
g_object_unref(notification);
146
lasso_samlp_request_abstract_set_requestID(LASSO_SAMLP_REQUEST_ABSTRACT(notification), str);
149
str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "MajorVersion"), 0);
151
g_datalist_clear(&gd);
152
g_object_unref(notification);
155
lasso_samlp_request_abstract_set_majorVersion(LASSO_SAMLP_REQUEST_ABSTRACT(notification), str);
158
str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "MinorVersion"), 0);
160
g_datalist_clear(&gd);
161
g_object_unref(notification);
164
lasso_samlp_request_abstract_set_minorVersion(LASSO_SAMLP_REQUEST_ABSTRACT(notification), str);
167
str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "IssueInstant"), 0);
169
g_datalist_clear(&gd);
170
g_object_unref(notification);
173
lasso_samlp_request_abstract_set_issueInstant(LASSO_SAMLP_REQUEST_ABSTRACT(notification), str);
176
str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "ProviderID"), 0);
178
g_datalist_clear(&gd);
179
g_object_unref(notification);
182
lasso_lib_federation_termination_notification_set_providerID(LASSO_LIB_FEDERATION_TERMINATION_NOTIFICATION(notification), str);
185
str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "NameIdentifier"), 0);
187
g_datalist_clear(&gd);
188
g_object_unref(notification);
191
identifier = lasso_saml_name_identifier_new(str);
192
str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "NameQualifier"), 0);
194
g_datalist_clear(&gd);
195
g_object_unref(notification);
198
lasso_saml_name_identifier_set_nameQualifier(LASSO_SAML_NAME_IDENTIFIER(identifier), str);
199
str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "Format"), 0);
201
g_datalist_clear(&gd);
202
g_object_unref(notification);
205
lasso_saml_name_identifier_set_format(LASSO_SAML_NAME_IDENTIFIER(identifier), str);
207
lasso_lib_federation_termination_notification_set_nameIdentifier(LASSO_LIB_FEDERATION_TERMINATION_NOTIFICATION(notification),
208
LASSO_SAML_NAME_IDENTIFIER(identifier));
210
lasso_node_destroy(identifier);
216
lasso_federation_termination_notification_new_from_soap(const gchar *buffer)
218
LassoNode *notification;
219
LassoNode *envelope, *lassoNode_notification;
220
xmlNodePtr xmlNode_notification;
221
LassoNodeClass *class;
223
notification = LASSO_NODE(g_object_new(LASSO_TYPE_FEDERATION_TERMINATION_NOTIFICATION, NULL));
225
envelope = lasso_node_new_from_dump(buffer);
226
lassoNode_notification = lasso_node_get_child(envelope, "FederationTerminationNotification",
229
class = LASSO_NODE_GET_CLASS(lassoNode_notification);
230
xmlNode_notification = xmlCopyNode(class->get_xmlNode(LASSO_NODE(lassoNode_notification)), 1);
231
lasso_node_destroy(lassoNode_notification);
233
class = LASSO_NODE_GET_CLASS(notification);
234
class->set_xmlNode(LASSO_NODE(notification), xmlNode_notification);
235
lasso_node_destroy(envelope);
242
lasso_federation_termination_notification_new_from_export(const gchar *buffer,
243
lassoNodeExportType export_type)
245
LassoNode *notification;
247
g_return_val_if_fail(buffer != NULL, NULL);
250
case lassoNodeExportTypeQuery:
251
notification = lasso_federation_termination_notification_new_from_query(buffer);
253
case lassoNodeExportTypeSoap:
254
notification = lasso_federation_termination_notification_new_from_soap(buffer);