~ubuntu-branches/ubuntu/breezy/lasso/breezy

« back to all changes in this revision

Viewing changes to lasso/protocols/federation_termination_notification.c

  • Committer: Bazaar Package Importer
  • Author(s): Stephan Hermann
  • Date: 2005-09-16 02:16:49 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050916021649-lr5tuka6pfmmks44
Tags: 0.6.2-3ubuntu1
* debian/control: removed hardcoded php dependency, added php:Depends
  substvar
* debian/rules: added phpapiver, added substitution of php:Depends

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: federation_termination_notification.c,v 1.22 2004/09/01 09:59:53 fpeters Exp $ 
2
 
 *
3
 
 * Lasso - A free implementation of the Liberty Alliance specifications.
4
 
 *
5
 
 * Copyright (C) 2004 Entr'ouvert
6
 
 * http://lasso.entrouvert.org
7
 
 * 
8
 
 * Authors: Valery Febvre   <vfebvre@easter-eggs.com>
9
 
 *          Nicolas Clapies <nclapies@entrouvert.com>
10
 
 *
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.
15
 
 * 
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.
20
 
 * 
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
24
 
 */
25
 
 
26
 
#include <lasso/protocols/federation_termination_notification.h>
27
 
#include <lasso/xml/saml_name_identifier.h>
28
 
 
29
 
/*****************************************************************************/
30
 
/* public methods                                                            */
31
 
/*****************************************************************************/
32
 
 
33
 
/*****************************************************************************/
34
 
/* instance and class init functions                                         */
35
 
/*****************************************************************************/
36
 
 
37
 
static void
38
 
lasso_federation_termination_notification_instance_init(LassoFederationTerminationNotification *request)
39
 
{
40
 
}
41
 
 
42
 
static void
43
 
lasso_federation_termination_notification_class_init(LassoFederationTerminationNotificationClass *class)
44
 
{
45
 
}
46
 
 
47
 
GType lasso_federation_termination_notification_get_type() {
48
 
  static GType this_type = 0;
49
 
 
50
 
  if (!this_type) {
51
 
    static const GTypeInfo this_info = {
52
 
      sizeof (LassoFederationTerminationNotificationClass),
53
 
      NULL,
54
 
      NULL,
55
 
      (GClassInitFunc) lasso_federation_termination_notification_class_init,
56
 
      NULL,
57
 
      NULL,
58
 
      sizeof(LassoFederationTerminationNotification),
59
 
      0,
60
 
      (GInstanceInitFunc) lasso_federation_termination_notification_instance_init,
61
 
    };
62
 
    
63
 
    this_type = g_type_register_static(LASSO_TYPE_LIB_FEDERATION_TERMINATION_NOTIFICATION,
64
 
                                       "LassoFederationTerminationNotification",
65
 
                                       &this_info, 0);
66
 
  }
67
 
  return this_type;
68
 
}
69
 
 
70
 
LassoNode*
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)
77
 
{
78
 
  LassoNode *request, *identifier;
79
 
  xmlChar *id, *time;
80
 
 
81
 
  request = LASSO_NODE(g_object_new(LASSO_TYPE_FEDERATION_TERMINATION_NOTIFICATION, NULL));
82
 
  
83
 
  /* Set ONLY required elements/attributes */
84
 
  /* RequestID */
85
 
  id = lasso_build_unique_id(32);
86
 
  lasso_samlp_request_abstract_set_requestID(LASSO_SAMLP_REQUEST_ABSTRACT(request),
87
 
                                             (const xmlChar *)id);
88
 
  xmlFree(id);
89
 
  /* MajorVersion */
90
 
  lasso_samlp_request_abstract_set_majorVersion(LASSO_SAMLP_REQUEST_ABSTRACT(request),
91
 
                                                lassoLibMajorVersion);
92
 
  /* MinorVersion */
93
 
  lasso_samlp_request_abstract_set_minorVersion(LASSO_SAMLP_REQUEST_ABSTRACT(request), 
94
 
                                                lassoLibMinorVersion);
95
 
  /* IssueInstant */
96
 
  time = lasso_get_current_time();
97
 
  lasso_samlp_request_abstract_set_issueInstant(LASSO_SAMLP_REQUEST_ABSTRACT(request),
98
 
                                                (const xmlChar *)time);
99
 
  xmlFree(time);
100
 
 
101
 
  /* set the signature template */
102
 
  if (sign_type != lassoSignatureTypeNone) {
103
 
    lasso_samlp_request_abstract_set_signature_tmpl(LASSO_SAMLP_REQUEST_ABSTRACT(request),
104
 
                                                    sign_type,
105
 
                                                    sign_method,
106
 
                                                    NULL);
107
 
  }
108
 
 
109
 
  /* ProviderID */
110
 
  lasso_lib_federation_termination_notification_set_providerID(LASSO_LIB_FEDERATION_TERMINATION_NOTIFICATION(request),
111
 
                                         providerID);
112
 
 
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);
116
 
 
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);
120
 
 
121
 
  return request;
122
 
}
123
 
 
124
 
LassoNode *
125
 
lasso_federation_termination_notification_new_from_query(const gchar *query)
126
 
{
127
 
  LassoNode *notification, *identifier;
128
 
  xmlChar *str;
129
 
  GData *gd;
130
 
  
131
 
  notification = LASSO_NODE(g_object_new(LASSO_TYPE_FEDERATION_TERMINATION_NOTIFICATION, NULL));
132
 
  
133
 
  gd = lasso_query_to_dict(query);
134
 
  if (gd == NULL) {
135
 
    g_object_unref(notification);
136
 
    return NULL;
137
 
  }
138
 
  
139
 
  /* RequestID */
140
 
  str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "RequestID"), 0);
141
 
  if (str == NULL) {
142
 
    g_datalist_clear(&gd);
143
 
    g_object_unref(notification);
144
 
    return NULL;
145
 
  }
146
 
  lasso_samlp_request_abstract_set_requestID(LASSO_SAMLP_REQUEST_ABSTRACT(notification), str);
147
 
  
148
 
  /* MajorVersion */
149
 
  str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "MajorVersion"), 0);
150
 
  if (str == NULL) {
151
 
    g_datalist_clear(&gd);
152
 
    g_object_unref(notification);
153
 
    return (NULL);    
154
 
  }
155
 
  lasso_samlp_request_abstract_set_majorVersion(LASSO_SAMLP_REQUEST_ABSTRACT(notification), str);
156
 
  
157
 
  /* MinorVersion */
158
 
  str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "MinorVersion"), 0);
159
 
  if (str == NULL) {
160
 
    g_datalist_clear(&gd);
161
 
    g_object_unref(notification);
162
 
    return NULL;
163
 
  }
164
 
  lasso_samlp_request_abstract_set_minorVersion(LASSO_SAMLP_REQUEST_ABSTRACT(notification), str);
165
 
  
166
 
  /* IssueInstant */
167
 
  str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "IssueInstant"), 0);
168
 
  if (str == NULL) {
169
 
    g_datalist_clear(&gd);
170
 
    g_object_unref(notification);
171
 
    return NULL;
172
 
  }
173
 
  lasso_samlp_request_abstract_set_issueInstant(LASSO_SAMLP_REQUEST_ABSTRACT(notification), str);
174
 
  
175
 
  /* ProviderID */
176
 
  str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "ProviderID"), 0);
177
 
  if (str == NULL) {
178
 
    g_datalist_clear(&gd);
179
 
    g_object_unref(notification);
180
 
    return NULL;
181
 
  }
182
 
  lasso_lib_federation_termination_notification_set_providerID(LASSO_LIB_FEDERATION_TERMINATION_NOTIFICATION(notification), str);
183
 
  
184
 
  /* NameIdentifier */
185
 
  str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "NameIdentifier"), 0);
186
 
  if (str == NULL) {
187
 
    g_datalist_clear(&gd);
188
 
    g_object_unref(notification);
189
 
    return NULL;
190
 
  }
191
 
  identifier = lasso_saml_name_identifier_new(str);
192
 
  str = lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "NameQualifier"), 0);
193
 
  if (str == NULL) {
194
 
    g_datalist_clear(&gd);
195
 
    g_object_unref(notification);
196
 
    return NULL;
197
 
  }
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);
200
 
  if (str == NULL) {
201
 
    g_datalist_clear(&gd);
202
 
    g_object_unref(notification);
203
 
    return NULL;
204
 
  }
205
 
  lasso_saml_name_identifier_set_format(LASSO_SAML_NAME_IDENTIFIER(identifier), str);
206
 
  
207
 
  lasso_lib_federation_termination_notification_set_nameIdentifier(LASSO_LIB_FEDERATION_TERMINATION_NOTIFICATION(notification),
208
 
                                                                   LASSO_SAML_NAME_IDENTIFIER(identifier));
209
 
  
210
 
  lasso_node_destroy(identifier);
211
 
 
212
 
  return notification;
213
 
}
214
 
 
215
 
LassoNode *
216
 
lasso_federation_termination_notification_new_from_soap(const gchar *buffer)
217
 
{
218
 
  LassoNode *notification;
219
 
  LassoNode *envelope, *lassoNode_notification;
220
 
  xmlNodePtr xmlNode_notification;
221
 
  LassoNodeClass *class;
222
 
  
223
 
  notification = LASSO_NODE(g_object_new(LASSO_TYPE_FEDERATION_TERMINATION_NOTIFICATION, NULL));
224
 
  
225
 
  envelope = lasso_node_new_from_dump(buffer);
226
 
  lassoNode_notification = lasso_node_get_child(envelope, "FederationTerminationNotification",
227
 
                                                lassoLibHRef, NULL);
228
 
  
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);
232
 
  
233
 
  class = LASSO_NODE_GET_CLASS(notification);
234
 
  class->set_xmlNode(LASSO_NODE(notification), xmlNode_notification);
235
 
  lasso_node_destroy(envelope);
236
 
  
237
 
  return notification;
238
 
}
239
 
 
240
 
 
241
 
LassoNode*
242
 
lasso_federation_termination_notification_new_from_export(const gchar         *buffer,
243
 
                                                          lassoNodeExportType  export_type)
244
 
{
245
 
  LassoNode *notification;
246
 
 
247
 
  g_return_val_if_fail(buffer != NULL, NULL);
248
 
 
249
 
  switch(export_type){
250
 
  case lassoNodeExportTypeQuery:
251
 
    notification = lasso_federation_termination_notification_new_from_query(buffer);
252
 
    break;
253
 
  case lassoNodeExportTypeSoap:
254
 
    notification = lasso_federation_termination_notification_new_from_soap(buffer);
255
 
    break;
256
 
  default:
257
 
    return NULL;
258
 
  }
259
 
 
260
 
  return notification;
261
 
}