~ubuntu-branches/ubuntu/hardy/lasso/hardy

« back to all changes in this revision

Viewing changes to lasso/id-wsf/authentication.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Bienia
  • Date: 2007-07-31 21:35:26 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070731213526-oc6jw5mprcd5tjyy
Tags: 2.0.0-1ubuntu1
* Merge from debian unstable. Remaining changes:
  + debian/control:
    - Modify Maintainer value to match DebianMaintainerField spec.
* debian/rules:
  + Add CC=gcc-4.2 to the configure call else configure won't find jni.h
    from libgcj8-dev.
* configure{,.ac}:
  + Add missing quotes around the value for PHP[45]_LIBS.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: authentication.c,v 1.10 2006/03/04 15:50:31 fpeters Exp $ 
 
1
/* $Id: authentication.c,v 1.19 2007/01/06 22:53:19 fpeters Exp $ 
2
2
 *
3
3
 * Lasso - A free implementation of the Liberty Alliance specifications.
4
4
 *
34
34
static int
35
35
lasso_sasl_cb_log(void* context, int priority, const char* message)
36
36
{
37
 
        printf("SASL lasso_sasl_cb_log() : %s\n", message);
38
 
 
39
37
        return SASL_OK;
40
38
}
41
39
 
64
62
        static sasl_secret_t *s;
65
63
        LassoUserAccount *account;
66
64
        int ret = SASL_FAIL;
67
 
   
 
65
 
68
66
        account = (LassoUserAccount *)context;
69
67
        if (account != NULL && account->password != NULL) {
70
68
                s = (sasl_secret_t*) g_malloc0(sizeof(sasl_secret_t) + strlen(account->password));
71
69
 
72
 
                strcpy(s->data, account->password);
 
70
                strcpy((char*)s->data, account->password);
73
71
                s->len = strlen(account->password);
74
72
 
75
73
                *psecret = s;
112
110
                g_free(request->mechanism);
113
111
                request->mechanism = g_strdup(mechusing);
114
112
        }
115
 
       
 
113
 
116
114
        if (outlen > 0) {
117
 
                outbase64 = xmlSecBase64Encode(out, outlen, 0);
 
115
                outbase64 = xmlSecBase64Encode((xmlChar*)out, outlen, 0);
118
116
                request->Data = g_list_append(request->Data, outbase64);
119
117
        }
120
118
 
141
139
 
142
140
        /* sasl part */
143
141
 
144
 
        if (response->Data != NULL) {
 
142
        if (response->Data != NULL && response->Data->data != NULL) {
145
143
                inbase64 = response->Data->data;
146
 
                in = g_malloc(strlen(inbase64));
147
 
                inlen = xmlSecBase64Decode(inbase64, in, strlen(inbase64));
 
144
                in = g_malloc(strlen((char*)inbase64));
 
145
                inlen = xmlSecBase64Decode(inbase64, in, strlen((char*)inbase64));
148
146
 
149
147
                res = sasl_client_step(authentication->connection, /* our context */
150
148
                                       in,    /* the data from the server */
208
206
        static sasl_callback_t global_callbacks[2];
209
207
 
210
208
        g_return_val_if_fail(LASSO_IS_AUTHENTICATION(authentication),
211
 
                             LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
 
209
                        LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
212
210
        g_return_val_if_fail(LASSO_IS_DISCO_DESCRIPTION(description),
213
 
                             LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
214
 
        g_return_val_if_fail(mechanisms != NULL, LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
 
211
                        LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
 
212
        g_return_val_if_fail(mechanisms != NULL, LASSO_PARAM_ERROR_INVALID_VALUE);
215
213
 
216
214
 
217
215
        if (description->Endpoint != NULL) {
218
216
                LASSO_WSF_PROFILE(authentication)->msg_url = g_strdup(description->Endpoint);
219
 
        }
220
 
        else if (description->WsdlURI != NULL) {
 
217
        } else if (description->WsdlURI != NULL) {
221
218
 
222
219
        }
223
220
 
230
227
 
231
228
        envelope = lasso_wsf_profile_build_soap_envelope(NULL, NULL);
232
229
        LASSO_WSF_PROFILE(authentication)->soap_envelope_request = envelope;
 
230
        if (envelope == NULL || envelope->Body == NULL || envelope->Body->any == NULL) {
 
231
                return critical_error(LASSO_PROFILE_ERROR_MISSING_REQUEST);
 
232
        }
233
233
        envelope->Body->any = g_list_append(envelope->Body->any, request);
234
234
 
235
235
        /* set up default logging callback */
298
298
        int res = 0;
299
299
        
300
300
        g_return_val_if_fail(LASSO_IS_AUTHENTICATION(authentication),
301
 
                             LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
302
 
 
 
301
                        LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
303
302
        g_return_val_if_fail(LASSO_IS_AUTHENTICATION(authentication),
304
 
                             LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
305
 
        g_return_val_if_fail(soap_msg != NULL, LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
 
303
                        LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
 
304
        g_return_val_if_fail(soap_msg != NULL, LASSO_PARAM_ERROR_INVALID_VALUE);
306
305
 
307
306
        /* if a previous request and response, then remove */
308
307
        if (LASSO_IS_SOAP_ENVELOPE(LASSO_WSF_PROFILE(authentication)->soap_envelope_response) \
333
332
        status = lasso_utility_status_new(LASSO_SA_STATUS_CODE_OK);
334
333
        response = lasso_sa_sasl_response_new(status);
335
334
        LASSO_WSF_PROFILE(authentication)->response = LASSO_NODE(response);
 
335
        if (envelope == NULL || envelope->Body == NULL || envelope->Body->any == NULL) {
 
336
                return critical_error(LASSO_PROFILE_ERROR_MISSING_RESPONSE);
 
337
        }
336
338
        envelope->Body->any = g_list_append(envelope->Body->any, response);
337
339
 
338
340
        /* liberty-idwsf-authn-svc-1.1.pdf - page 13 - lignes 359 / 361 :
359
361
        gchar *messageId;
360
362
 
361
363
        g_return_val_if_fail(LASSO_IS_AUTHENTICATION(authentication),
362
 
                             LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
363
 
        g_return_val_if_fail(soap_msg != NULL, LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
 
364
                        LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
 
365
        g_return_val_if_fail(soap_msg != NULL, LASSO_PARAM_ERROR_INVALID_VALUE);
364
366
 
365
367
        /* if a previous request or response, remove */
366
368
        if (LASSO_IS_SOAP_ENVELOPE(LASSO_WSF_PROFILE(authentication)->soap_envelope_request) \
382
384
        envelope = LASSO_SOAP_ENVELOPE(lasso_node_new_from_dump(soap_msg));
383
385
        LASSO_WSF_PROFILE(authentication)->soap_envelope_response = envelope;
384
386
 
 
387
        if (envelope == NULL || envelope->Body == NULL || envelope->Body->any == NULL) {
 
388
                return critical_error(LASSO_PROFILE_ERROR_MISSING_RESPONSE);
 
389
        }
385
390
        response = envelope->Body->any->data;
 
391
        if (response == NULL) {
 
392
                return critical_error(LASSO_PROFILE_ERROR_MISSING_RESPONSE);
 
393
        }
386
394
        LASSO_WSF_PROFILE(authentication)->response = LASSO_NODE(response);
387
395
 
 
396
        if (response->Status == NULL || response->Status->code == NULL) {
 
397
                return critical_error(LASSO_PROFILE_ERROR_MISSING_STATUS_CODE);
 
398
        }
 
399
 
388
400
        /* if continue, init another request */
389
401
        if (g_str_equal(response->Status->code, LASSO_SA_STATUS_CODE_CONTINUE) == TRUE) {
390
402
                correlation = envelope->Header->Other->data;
483
495
        }
484
496
 
485
497
        /* decode Data if not NULL */
486
 
        if (request->Data != NULL) {
 
498
        if (request->Data != NULL && request->Data->data != NULL) {
487
499
                inbase64 = request->Data->data;
488
500
                in = g_malloc(strlen(inbase64));
489
501
                inlen = xmlSecBase64Decode(inbase64, in, strlen(inbase64));
509
521
                                outbase64 = xmlSecBase64Encode(out, outlen, 0);
510
522
                                response->Data = g_list_append(response->Data, outbase64);
511
523
                        }
512
 
                }
513
 
                /* abort authentication */
514
 
                else {
 
524
                } else {
 
525
                        /* abort authentication */
515
526
                        response->Status->code = g_strdup(LASSO_SA_STATUS_CODE_ABORT);
516
527
                }
517
528
        }
546
557
                return 0;
547
558
        }
548
559
 
549
 
        if (request->Data != NULL) {
 
560
        if (request->Data != NULL && request->Data->data != NULL) {
550
561
                inbase64 = request->Data->data;
551
562
                in = g_malloc(strlen(inbase64));
552
563
                inlen = xmlSecBase64Decode(inbase64, in, strlen(inbase64));
569
580
                                outbase64 = xmlSecBase64Encode(out, outlen, 0);
570
581
                                response->Data = g_list_append(response->Data, outbase64);
571
582
                        }
572
 
                }
 
583
                } else  {
573
584
                /* authentication failed, abort exchange */
574
 
                else  {
575
585
                        response->Status->code = g_strdup(LASSO_SA_STATUS_CODE_ABORT);
576
586
                }
577
587
        }