~ubuntu-branches/ubuntu/utopic/lasso/utopic-proposed

« back to all changes in this revision

Viewing changes to lasso/environs/name_registration.c

  • Committer: Bazaar Package Importer
  • Author(s): Frederic Peters
  • Date: 2004-09-13 09:26:34 UTC
  • Revision ID: james.westby@ubuntu.com-20040913092634-01vdfl8j9cp94exa
Tags: upstream-0.4.1
ImportĀ upstreamĀ versionĀ 0.4.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: name_registration.c,v 1.5 2004/09/04 10:36:32 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: Nicolas Clapies <nclapies@entrouvert.com>
 
9
 *          Valery Febvre <vfebvre@easter-eggs.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 <string.h>
 
27
#include <glib/gprintf.h>
 
28
 
 
29
#include <lasso/environs/name_registration.h>
 
30
 
 
31
static GObjectClass *parent_class = NULL;
 
32
 
 
33
/*****************************************************************************/
 
34
/* public methods                                                            */
 
35
/*****************************************************************************/
 
36
 
 
37
/**
 
38
 * lasso_name_registration_dump:
 
39
 * @name_registration: the register name identifier object
 
40
 * 
 
41
 * This method builds a dump of the register name identifier object
 
42
 * 
 
43
 * Return value: a newly allocated string or NULL
 
44
 **/
 
45
gchar *
 
46
lasso_name_registration_dump(LassoNameRegistration *name_registration)
 
47
{
 
48
  gchar *dump;
 
49
 
 
50
  g_return_val_if_fail(LASSO_IS_NAME_REGISTRATION(name_registration), NULL);
 
51
 
 
52
  dump = NULL;
 
53
 
 
54
  return dump;
 
55
}
 
56
 
 
57
/**
 
58
 * lasso_name_registration_build_request_msg:
 
59
 * @name_registration: the register name identifier object
 
60
 * 
 
61
 * This method build a register name identifier request message.
 
62
 * 
 
63
 * It gets the register name identifier protocol profile and :
 
64
 *    if it is a SOAP method, then it builds the register name identifier request SOAP message,
 
65
 *    optionaly signs his node, set the msg_body attribute, gets the SoapEndpoint
 
66
 *    url and set the msg_url attribute.
 
67
 *
 
68
 *    if it is a HTTP-Redirect method, then it builds the register name identifier request QUERY message
 
69
 *    ( optionaly signs the request message ), builds the request url with register name identifier url
 
70
 *    with register name identifier service url, set the msg_url attribute of the register name identifier
 
71
 *    object, set the msg_body to NULL.
 
72
 * 
 
73
 * Return value: 0 if OK else < 0
 
74
 **/
 
75
gint
 
76
lasso_name_registration_build_request_msg(LassoNameRegistration *name_registration)
 
77
{
 
78
  LassoProfile  *profile;
 
79
  LassoProvider *provider;
 
80
  xmlChar       *protocolProfile;
 
81
  gint           ret = 0;
 
82
 
 
83
  g_return_val_if_fail(LASSO_IS_NAME_REGISTRATION(name_registration), -1);
 
84
  
 
85
  profile = LASSO_PROFILE(name_registration);
 
86
 
 
87
  /* get the provider */
 
88
  provider = lasso_server_get_provider_ref(profile->server,
 
89
                                           profile->remote_providerID,
 
90
                                           NULL);
 
91
  if (provider == NULL) {
 
92
    message(G_LOG_LEVEL_CRITICAL, "Provider %s not found\n", profile->remote_providerID);
 
93
    ret = -1;
 
94
    goto done;
 
95
  }
 
96
 
 
97
  /* get the prototocol profile of the name_registration */
 
98
  protocolProfile = lasso_provider_get_registerNameIdentifierProtocolProfile(provider,
 
99
                                                                             lassoProviderTypeIdp,
 
100
                                                                             NULL);
 
101
  if (protocolProfile == NULL) {
 
102
    message(G_LOG_LEVEL_CRITICAL, "Name_Registration Protocol profile not found\n");
 
103
    ret = -1;
 
104
    goto done;
 
105
  }
 
106
 
 
107
  if (xmlStrEqual(protocolProfile, lassoLibProtocolProfileRniIdpSoap) || \
 
108
      xmlStrEqual(protocolProfile, lassoLibProtocolProfileRniSpSoap)) {
 
109
    profile->request_type = lassoHttpMethodSoap;
 
110
    /* sign the request message */
 
111
    lasso_samlp_request_abstract_set_signature(LASSO_SAMLP_REQUEST_ABSTRACT(profile->request),
 
112
                                               profile->server->signature_method,
 
113
                                               profile->server->private_key,
 
114
                                               profile->server->certificate);
 
115
    
 
116
    /* build the registration request message */
 
117
    profile->msg_url  = lasso_provider_get_soapEndpoint(provider,
 
118
                                                        lassoProviderTypeIdp,
 
119
                                                        NULL);
 
120
    profile->msg_body = lasso_node_export_to_soap(profile->request);
 
121
  }
 
122
  else if (xmlStrEqual(protocolProfile,lassoLibProtocolProfileRniIdpHttp) || \
 
123
           xmlStrEqual(protocolProfile,lassoLibProtocolProfileRniSpHttp)) {
 
124
    /* temporary vars to store url, query and separator */
 
125
    gchar *url, *query;
 
126
 
 
127
    /* build and optionaly sign the query message and build the register name
 
128
     * identifier request url */
 
129
    url = lasso_provider_get_registerNameIdentifierServiceURL(provider, profile->provider_type, NULL);
 
130
    query = lasso_node_export_to_query(profile->request,
 
131
                                       profile->server->signature_method,
 
132
                                       profile->server->private_key);
 
133
 
 
134
    profile->msg_url = g_new(gchar, strlen(url)+strlen(query)+1+1);
 
135
    g_sprintf(profile->msg_url, "%s?%s", url, query);
 
136
    profile->msg_body = NULL;
 
137
 
 
138
    xmlFree(url);
 
139
    xmlFree(query);
 
140
  }
 
141
  else {
 
142
    message(G_LOG_LEVEL_CRITICAL, "Invalid protocol Profile for register name identifier\n");
 
143
    ret = -1;
 
144
    goto done;
 
145
  }
 
146
 
 
147
  done:
 
148
 
 
149
  return ret;
 
150
}
 
151
 
 
152
gint
 
153
lasso_name_registration_build_response_msg(LassoNameRegistration *name_registration)
 
154
{
 
155
  LassoProfile *profile;
 
156
  LassoProvider *provider;
 
157
  xmlChar *protocolProfile;
 
158
  
 
159
  g_return_val_if_fail(LASSO_IS_NAME_REGISTRATION(name_registration), -1);
 
160
 
 
161
  profile = LASSO_PROFILE(name_registration);
 
162
 
 
163
  provider = lasso_server_get_provider_ref(profile->server,
 
164
                                           profile->remote_providerID,
 
165
                                           NULL);
 
166
  if (provider == NULL) {
 
167
    message(G_LOG_LEVEL_CRITICAL, "Provider not found (ProviderID = %s)\n", profile->remote_providerID);
 
168
    return -2;
 
169
  }
 
170
 
 
171
  protocolProfile = lasso_provider_get_registerNameIdentifierProtocolProfile(provider,
 
172
                                                                             lassoProviderTypeSp,
 
173
                                                                             NULL);
 
174
  if (protocolProfile == NULL) {
 
175
    message(G_LOG_LEVEL_CRITICAL, "Register name identifier protocol profile not found\n");
 
176
    return -3;
 
177
  }
 
178
 
 
179
  if (xmlStrEqual(protocolProfile, lassoLibProtocolProfileSloSpSoap) || \
 
180
      xmlStrEqual(protocolProfile, lassoLibProtocolProfileSloIdpSoap)) {
 
181
    debug("building a soap response message\n");
 
182
    profile->msg_url = lasso_provider_get_registerNameIdentifierServiceURL(provider,
 
183
                                                                           lassoProviderTypeSp,
 
184
                                                                           NULL);
 
185
    profile->msg_body = lasso_node_export_to_soap(profile->response);
 
186
  }
 
187
  else if (xmlStrEqual(protocolProfile,lassoLibProtocolProfileSloSpHttp) || \
 
188
           xmlStrEqual(protocolProfile,lassoLibProtocolProfileSloIdpHttp)) {
 
189
    debug("building a http get response message\n");
 
190
  }
 
191
 
 
192
  return 0;
 
193
}
 
194
 
 
195
void
 
196
lasso_name_registration_destroy(LassoNameRegistration *name_registration)
 
197
{
 
198
  g_object_unref(G_OBJECT(name_registration));
 
199
}
 
200
 
 
201
gint
 
202
lasso_name_registration_init_request(LassoNameRegistration *name_registration,
 
203
                                            gchar                       *remote_providerID)
 
204
{
 
205
  LassoProfile    *profile;
 
206
  LassoNode       *nameIdentifier_node;
 
207
  LassoFederation *federation;
 
208
 
 
209
  xmlChar *spNameIdentifier,  *spNameQualifier, *spFormat;
 
210
  xmlChar *idpNameIdentifier, *idpNameQualifier, *idpFormat;
 
211
  xmlChar *oldNameIdentifier = NULL, *oldNameQualifier = NULL, *oldFormat = NULL;
 
212
 
 
213
  gint ret = 0;
 
214
 
 
215
  g_return_val_if_fail(LASSO_IS_NAME_REGISTRATION(name_registration), -1);
 
216
 
 
217
  profile = LASSO_PROFILE(name_registration);
 
218
 
 
219
  if (remote_providerID == NULL) {
 
220
    message(G_LOG_LEVEL_INFO, "No remote provider id, get the next federation peer provider id\n");
 
221
    profile->remote_providerID = lasso_identity_get_next_federation_remote_providerID(profile->identity);
 
222
  }
 
223
  else {
 
224
    message(G_LOG_LEVEL_INFO, "A remote provider id for register name identifier request : %s\n", remote_providerID);
 
225
    profile->remote_providerID = g_strdup(remote_providerID);
 
226
  }
 
227
  if (profile->remote_providerID == NULL) {
 
228
    message(G_LOG_LEVEL_CRITICAL, "No provider id for init request\n");
 
229
    ret = -1;
 
230
    goto done;
 
231
  }
 
232
 
 
233
  /* get federation */
 
234
  federation = lasso_identity_get_federation(profile->identity, profile->remote_providerID);
 
235
  if (federation == NULL) {
 
236
    message(G_LOG_LEVEL_CRITICAL, "Federation not found\n");
 
237
    ret = -1;
 
238
    goto done;
 
239
  }
 
240
  switch (profile->provider_type) {
 
241
  case lassoProviderTypeSp:
 
242
    /* set the new name identifier */
 
243
    spNameIdentifier = lasso_build_unique_id(32);
 
244
    spNameQualifier  = g_strdup(profile->remote_providerID);
 
245
    spFormat         = "federated";
 
246
 
 
247
    /* set the old name identifier */
 
248
    nameIdentifier_node = lasso_federation_get_local_nameIdentifier(federation);
 
249
    if (nameIdentifier_node != NULL) {
 
250
      oldNameIdentifier = lasso_node_get_content(nameIdentifier_node, NULL);
 
251
      oldNameQualifier  = lasso_node_get_attr_value(nameIdentifier_node, "NameQualifier", NULL);
 
252
      oldFormat         = lasso_node_get_attr_value(nameIdentifier_node, "Format", NULL);
 
253
    }
 
254
    lasso_node_destroy(nameIdentifier_node);
 
255
 
 
256
    /* idp name identifier */
 
257
    nameIdentifier_node = lasso_federation_get_remote_nameIdentifier(federation);
 
258
    if (nameIdentifier_node == NULL) {
 
259
      message(G_LOG_LEVEL_CRITICAL, "Remote NameIdentifier for service provider not found\n");
 
260
      ret = -1;
 
261
      goto done;
 
262
    }
 
263
    idpNameIdentifier   = lasso_node_get_content(nameIdentifier_node, NULL);
 
264
    idpNameQualifier    = lasso_node_get_attr_value(nameIdentifier_node, "NameQualifier", NULL);
 
265
    idpFormat           = lasso_node_get_attr_value(nameIdentifier_node, "Format", NULL);
 
266
    lasso_node_destroy(nameIdentifier_node);
 
267
 
 
268
    /* if old name identifier (Service provider) not found, set with federation provider */
 
269
    if (oldNameIdentifier == NULL) {
 
270
      oldNameIdentifier = g_strdup(idpNameIdentifier);
 
271
      oldNameQualifier  = g_strdup(idpNameQualifier);
 
272
      oldFormat         = g_strdup(idpFormat);
 
273
    }
 
274
    break;
 
275
 
 
276
  case lassoProviderTypeIdp:
 
277
    debug("Federation Provider\n");
 
278
    idpNameIdentifier = lasso_build_unique_id(32);
 
279
    idpNameQualifier  = g_strdup(profile->remote_providerID);
 
280
    idpFormat         = "federated";
 
281
 
 
282
    nameIdentifier_node = lasso_federation_get_local_nameIdentifier(federation);
 
283
    oldNameIdentifier   = lasso_node_get_content(nameIdentifier_node, NULL);
 
284
    oldNameQualifier    = lasso_node_get_attr_value(nameIdentifier_node, "NameQualifier", NULL);
 
285
    oldFormat           = lasso_node_get_attr_value(nameIdentifier_node, "Format", NULL);
 
286
 
 
287
    nameIdentifier_node = lasso_federation_get_remote_nameIdentifier(federation);
 
288
    if (nameIdentifier_node != NULL) {
 
289
      spNameIdentifier = lasso_node_get_content(nameIdentifier_node, NULL);
 
290
      spNameQualifier  = lasso_node_get_attr_value(nameIdentifier_node, "NameQualifier", NULL);
 
291
      spFormat         = lasso_node_get_attr_value(nameIdentifier_node, "Format", NULL);
 
292
    }
 
293
    else{
 
294
      spNameIdentifier = g_strdup(oldNameIdentifier);
 
295
      spNameQualifier  = g_strdup(oldNameQualifier);
 
296
      spFormat         = g_strdup(oldFormat);
 
297
    }
 
298
    break;
 
299
 
 
300
  default:
 
301
    message(G_LOG_LEVEL_CRITICAL, "Invalid provider type (%d)\n", profile->provider_type);
 
302
    ret = -1;
 
303
    goto done;
 
304
  }
 
305
  lasso_federation_destroy(federation);
 
306
 
 
307
  debug("old name identifier : %s, old name qualifier : %s, old format : %s\n", oldNameIdentifier, oldNameQualifier, oldFormat);
 
308
  debug("sp name identifier : %s, sp name qualifier : %s, sp format : %s\n",    spNameIdentifier,  spNameQualifier,  spFormat);
 
309
  debug("idp name identifier : %s, idp name qualifier : %s, idp format : %s\n", idpNameIdentifier, idpNameQualifier, idpFormat);
 
310
 
 
311
  profile->request = lasso_register_name_identifier_request_new(profile->server->providerID,
 
312
                                                                idpNameQualifier,
 
313
                                                                idpNameQualifier,
 
314
                                                                idpFormat,
 
315
                                                                spNameIdentifier,
 
316
                                                                spNameQualifier,
 
317
                                                                spFormat,
 
318
                                                                oldNameIdentifier,
 
319
                                                                oldNameQualifier,
 
320
                                                                oldFormat);
 
321
 
 
322
  if (profile->request == NULL) {
 
323
    message(G_LOG_LEVEL_CRITICAL, "Error while creating the request\n");
 
324
    ret = -1;
 
325
    goto done;
 
326
  }
 
327
 
 
328
  done:
 
329
 
 
330
  return ret;
 
331
}
 
332
 
 
333
gint lasso_name_registration_process_request_msg(LassoNameRegistration *name_registration,
 
334
                                                        gchar                       *request_msg,
 
335
                                                        lassoHttpMethod              request_method)
 
336
{
 
337
  LassoProfile *profile;
 
338
  gint          ret = 0;
 
339
 
 
340
  g_return_val_if_fail(LASSO_IS_NAME_REGISTRATION(name_registration), -1);
 
341
  g_return_val_if_fail(request_msg!=NULL, -1);
 
342
 
 
343
  profile = LASSO_PROFILE(name_registration);
 
344
 
 
345
  switch (request_method) {
 
346
  case lassoHttpMethodSoap:
 
347
    debug("Build a register name identifier request from soap msg\n");
 
348
    profile->request = lasso_register_name_identifier_request_new_from_export(request_msg, lassoNodeExportTypeSoap);
 
349
    break;
 
350
  case lassoHttpMethodRedirect:
 
351
    debug("Build a register name identifier request from query msg\n");
 
352
    profile->request = lasso_register_name_identifier_request_new_from_export(request_msg, lassoNodeExportTypeQuery);
 
353
    break;
 
354
  case lassoHttpMethodGet:
 
355
    debug("TODO, implement the get method\n");
 
356
    break;
 
357
  default:
 
358
    message(G_LOG_LEVEL_CRITICAL, "Invalid request method\n");
 
359
    ret = -1;
 
360
    goto done;
 
361
  }
 
362
  if (profile->request == NULL) {
 
363
    message(G_LOG_LEVEL_CRITICAL, "Error while building the request from msg\n");
 
364
    ret = -1;
 
365
    goto done;
 
366
  }
 
367
 
 
368
  /* get the NameIdentifier to load identity dump */
 
369
  profile->nameIdentifier = lasso_node_get_child_content(profile->request,
 
370
                                                         "NameIdentifier", NULL, NULL);
 
371
 
 
372
  /* get the RelayState */
 
373
  profile->msg_relayState = lasso_node_get_child_content(profile->request,
 
374
                                                         "RelayState", NULL, NULL);
 
375
 
 
376
  done :
 
377
 
 
378
  return ret;
 
379
}
 
380
 
 
381
gint
 
382
lasso_name_registration_validate_request(LassoNameRegistration *name_registration)
 
383
{
 
384
  LassoProfile    *profile;
 
385
  LassoFederation *federation;
 
386
  LassoNode       *nameIdentifier, *assertion;
 
387
  LassoNode       *statusCode;
 
388
  LassoNodeClass  *statusCode_class;
 
389
  gint             ret = 0;
 
390
 
 
391
  g_return_val_if_fail(LASSO_IS_NAME_REGISTRATION(name_registration), -1);
 
392
 
 
393
  profile = LASSO_PROFILE(name_registration);
 
394
 
 
395
  /* set the remote provider id from the request */
 
396
  profile->remote_providerID = lasso_node_get_child_content(profile->request, "ProviderID", NULL, NULL);
 
397
  if (profile->remote_providerID == NULL) {
 
398
    message(G_LOG_LEVEL_CRITICAL, "No provider id found in name_registration request\n");
 
399
    ret = -1;
 
400
    goto done;
 
401
  }
 
402
 
 
403
  /* set NameRegistrationResponse */
 
404
  profile->response = lasso_register_name_identifier_response_new(profile->server->providerID,
 
405
                                                                  (gchar *)lassoSamlStatusCodeSuccess,
 
406
                                                                  profile->request);
 
407
 
 
408
  if (profile->response == NULL) {
 
409
    message(G_LOG_LEVEL_CRITICAL, "Error while building response\n");
 
410
    ret = -1;
 
411
    goto done;
 
412
  }
 
413
 
 
414
  statusCode = lasso_node_get_child(profile->response, "StatusCode", NULL, NULL);
 
415
  statusCode_class = LASSO_NODE_GET_CLASS(statusCode);
 
416
 
 
417
  nameIdentifier = lasso_node_get_child(profile->request, "NameIdentifier", NULL, NULL);
 
418
  if (nameIdentifier == NULL) {
 
419
    message(G_LOG_LEVEL_CRITICAL, "No name identifier found in name_registration request\n");
 
420
    statusCode_class->set_prop(statusCode, "Value", lassoLibStatusCodeFederationDoesNotExist);
 
421
    ret = -1;
 
422
    goto done;
 
423
  }
 
424
 
 
425
  /* Verify federation */
 
426
  federation = lasso_identity_get_federation(profile->identity, profile->remote_providerID);
 
427
  if (federation == NULL) {
 
428
    message(G_LOG_LEVEL_WARNING, "No federation for %s\n", profile->remote_providerID);
 
429
    statusCode_class->set_prop(statusCode, "Value", lassoLibStatusCodeFederationDoesNotExist);
 
430
    ret = -1;
 
431
    goto done;
 
432
  }
 
433
 
 
434
  if (lasso_federation_verify_nameIdentifier(federation, nameIdentifier) == FALSE) {
 
435
    message(G_LOG_LEVEL_WARNING, "No name identifier for %s\n", profile->remote_providerID);
 
436
    statusCode_class->set_prop(statusCode, "Value", lassoLibStatusCodeFederationDoesNotExist);
 
437
    ret = -1;
 
438
    goto done;
 
439
  }
 
440
  lasso_federation_destroy(federation);
 
441
 
 
442
  /* verify authentication (if ok, delete assertion) */
 
443
  assertion = lasso_session_get_assertion(profile->session, profile->remote_providerID);
 
444
  if (assertion == NULL) {
 
445
    message(G_LOG_LEVEL_WARNING, "%s has no assertion\n", profile->remote_providerID);
 
446
    statusCode_class->set_prop(statusCode, "Value", lassoSamlStatusCodeRequestDenied);
 
447
    lasso_node_destroy(assertion);
 
448
    ret = -1;
 
449
    goto done;
 
450
  }
 
451
 
 
452
  done:
 
453
 
 
454
  return ret;
 
455
}
 
456
 
 
457
gint
 
458
lasso_name_registration_process_response_msg(LassoNameRegistration *name_registration,
 
459
                                                    gchar                       *response_msg,
 
460
                                                    lassoHttpMethod              response_method)
 
461
{
 
462
  LassoProfile *profile;
 
463
  xmlChar      *statusCodeValue;
 
464
  LassoNode    *statusCode;
 
465
  gint          ret = 0;
 
466
 
 
467
  g_return_val_if_fail(LASSO_IS_NAME_REGISTRATION(name_registration), -1);
 
468
  g_return_val_if_fail(response_msg != NULL, -1);
 
469
 
 
470
  profile = LASSO_PROFILE(name_registration);
 
471
 
 
472
  /* parse NameRegistrationResponse */
 
473
  switch (response_method) {
 
474
  case lassoHttpMethodSoap:
 
475
    profile->response = lasso_register_name_identifier_response_new_from_export(response_msg, lassoNodeExportTypeSoap);
 
476
    break;
 
477
  case lassoHttpMethodRedirect:
 
478
    profile->response = lasso_register_name_identifier_response_new_from_export(response_msg, lassoNodeExportTypeQuery);
 
479
    break;
 
480
  default:
 
481
    message(G_LOG_LEVEL_CRITICAL, "Unknown response method\n");
 
482
    ret = -1;
 
483
    goto done;
 
484
  }
 
485
 
 
486
  statusCode = lasso_node_get_child(profile->response, "StatusCode", NULL, NULL);
 
487
  if (statusCode == NULL) {
 
488
    message(G_LOG_LEVEL_CRITICAL, "StatusCode not found\n");
 
489
    ret = -1;
 
490
    goto done;
 
491
  }
 
492
  statusCodeValue = lasso_node_get_attr_value(statusCode, "Value", NULL);
 
493
  if (statusCodeValue == NULL) {
 
494
    message(G_LOG_LEVEL_CRITICAL, "StatusCodeValue not found\n");
 
495
    ret = -1;
 
496
    goto done;
 
497
  }
 
498
 
 
499
  if(!xmlStrEqual(statusCodeValue, lassoSamlStatusCodeSuccess)) {
 
500
    ret = -1;
 
501
    goto done;
 
502
  }
 
503
 
 
504
  done:
 
505
 
 
506
  return ret;
 
507
}
 
508
 
 
509
/*****************************************************************************/
 
510
/* overrided parent class methods                                            */
 
511
/*****************************************************************************/
 
512
 
 
513
static void
 
514
lasso_name_registration_finalize(LassoNameRegistration *name_registration)
 
515
{  
 
516
  message(G_LOG_LEVEL_INFO, "Register Name Identifier object 0x%x finalized ...\n", name_registration);
 
517
 
 
518
  parent_class->finalize(G_OBJECT(name_registration));
 
519
}
 
520
 
 
521
/*****************************************************************************/
 
522
/* instance and class init functions                                         */
 
523
/*****************************************************************************/
 
524
 
 
525
static void
 
526
lasso_name_registration_instance_init(LassoNameRegistration *name_registration)
 
527
{
 
528
}
 
529
 
 
530
static void
 
531
lasso_name_registration_class_init(LassoNameRegistrationClass *class)
 
532
{
 
533
  GObjectClass *gobject_class = G_OBJECT_CLASS(class);
 
534
  
 
535
  parent_class = g_type_class_peek_parent(class);
 
536
  /* override parent class methods */
 
537
  gobject_class->finalize = (void *)lasso_name_registration_finalize;
 
538
}
 
539
 
 
540
GType lasso_name_registration_get_type() {
 
541
  static GType this_type = 0;
 
542
 
 
543
  if (!this_type) {
 
544
    static const GTypeInfo this_info = {
 
545
      sizeof (LassoNameRegistrationClass),
 
546
      NULL,
 
547
      NULL,
 
548
      (GClassInitFunc) lasso_name_registration_class_init,
 
549
      NULL,
 
550
      NULL,
 
551
      sizeof(LassoNameRegistration),
 
552
      0,
 
553
      (GInstanceInitFunc) lasso_name_registration_instance_init,
 
554
    };
 
555
    
 
556
    this_type = g_type_register_static(LASSO_TYPE_PROFILE,
 
557
                                       "LassoNameRegistration",
 
558
                                       &this_info, 0);
 
559
  }
 
560
  return this_type;
 
561
}
 
562
 
 
563
LassoNameRegistration *
 
564
lasso_name_registration_new(LassoServer       *server,
 
565
                                   lassoProviderType  provider_type)
 
566
{
 
567
  LassoNameRegistration *name_registration;
 
568
 
 
569
  g_return_val_if_fail(LASSO_IS_SERVER(server), NULL);
 
570
 
 
571
  /* set the name_registration object */
 
572
  name_registration = g_object_new(LASSO_TYPE_NAME_REGISTRATION,
 
573
                                          "server", lasso_server_copy(server),
 
574
                                          "provider_type", provider_type,
 
575
                                          NULL);
 
576
 
 
577
  return name_registration;
 
578
}