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

« back to all changes in this revision

Viewing changes to lasso/id-ff/lecp.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: lecp.c,v 1.53 2006/01/23 15:30:00 fpeters Exp $
 
1
/* $Id: lecp.c,v 1.58 2007/01/05 13:40:07 fpeters Exp $
2
2
 *
3
3
 * Lasso - A free implementation of the Liberty Alliance specifications.
4
4
 *
50
50
        xmlOutputBuffer *buf;
51
51
        xmlCharEncodingHandler *handler;
52
52
 
53
 
        g_return_val_if_fail(LASSO_IS_LECP(lecp), -1);
 
53
        g_return_val_if_fail(LASSO_IS_LECP(lecp), LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
54
54
 
55
55
        profile = LASSO_PROFILE(lecp);
56
56
 
61
61
        }
62
62
 
63
63
        if (profile->request == NULL) {
64
 
                message(G_LOG_LEVEL_CRITICAL, "AuthnRequest not found");
65
 
                return LASSO_ERROR_UNDEFINED;
 
64
                return LASSO_PROFILE_ERROR_MISSING_REQUEST;
66
65
        }
67
66
 
68
67
        lecp->authnRequestEnvelope = lasso_lib_authn_request_envelope_new_full(
91
90
        xmlFreeNode(msg);
92
91
 
93
92
        if (profile->msg_body == NULL) {
94
 
                message(G_LOG_LEVEL_CRITICAL,
95
 
                                "Error while exporting the AuthnRequestEnvelope to POST msg");
96
 
                return LASSO_ERROR_UNDEFINED;
 
93
                return LASSO_PROFILE_ERROR_BUILDING_REQUEST_FAILED;
97
94
        }
98
95
 
99
96
        return 0;
114
111
        LassoProfile *profile;
115
112
        LassoProvider *remote_provider;
116
113
 
117
 
        g_return_val_if_fail(LASSO_IS_LECP(lecp), -1);
 
114
        g_return_val_if_fail(LASSO_IS_LECP(lecp), LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
118
115
 
119
116
        profile = LASSO_PROFILE(lecp);
120
117
 
151
148
{
152
149
        LassoProfile *profile;
153
150
 
154
 
        g_return_val_if_fail(LASSO_IS_LECP(lecp), -1);
 
151
        g_return_val_if_fail(LASSO_IS_LECP(lecp), LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
155
152
 
156
153
        profile = LASSO_PROFILE(lecp);
 
154
        lasso_profile_clean_msg_info(profile);
 
155
 
157
156
        profile->msg_url = g_strdup(lecp->assertionConsumerServiceURL);
158
157
        if (profile->msg_url == NULL) {
159
158
                return critical_error(LASSO_PROFILE_ERROR_UNKNOWN_PROFILE_URL);
183
182
        LassoProvider *provider;
184
183
        gchar *assertionConsumerServiceURL;
185
184
 
186
 
        g_return_val_if_fail(LASSO_IS_LECP(lecp), -1);
 
185
        g_return_val_if_fail(LASSO_IS_LECP(lecp), LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
187
186
 
188
187
        profile = LASSO_PROFILE(lecp);
189
188
 
190
189
        if (LASSO_IS_LIB_AUTHN_RESPONSE(profile->response) == FALSE) {
191
 
                message(G_LOG_LEVEL_CRITICAL, "AuthnResponse not found");
192
 
                return LASSO_ERROR_UNDEFINED;
 
190
                return LASSO_PROFILE_ERROR_MISSING_RESPONSE;
193
191
        }
194
192
 
195
193
        provider = g_hash_table_lookup(profile->server->providers, profile->remote_providerID);
244
242
{
245
243
        gint res;
246
244
 
247
 
        g_return_val_if_fail(LASSO_IS_LECP(lecp), -1);
 
245
        g_return_val_if_fail(LASSO_IS_LECP(lecp), LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
248
246
 
249
247
        /* FIXME : BAD usage of http_method
250
248
           using POST method so that the lib:AuthnRequest is initialize with
269
267
int
270
268
lasso_lecp_process_authn_request_msg(LassoLecp *lecp, const char *authn_request_msg)
271
269
{
272
 
        g_return_val_if_fail(LASSO_IS_LECP(lecp), -1);
273
 
        g_return_val_if_fail(authn_request_msg != NULL, -1);
 
270
        g_return_val_if_fail(LASSO_IS_LECP(lecp), LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
 
271
        g_return_val_if_fail(authn_request_msg != NULL, LASSO_PARAM_ERROR_INVALID_VALUE);
274
272
 
275
273
        return lasso_login_process_authn_request_msg(LASSO_LOGIN(lecp), authn_request_msg);
276
274
}
297
295
        xmlCharEncodingHandler *handler;
298
296
 
299
297
        g_return_val_if_fail(LASSO_IS_LECP(lecp), LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
300
 
        g_return_val_if_fail(request_msg != NULL, LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
 
298
        g_return_val_if_fail(request_msg != NULL, LASSO_PARAM_ERROR_INVALID_VALUE);
301
299
 
302
300
        doc = xmlParseMemory(request_msg, strlen(request_msg));
303
301
        xpathCtx = xmlXPathNewContext(doc);
305
303
        /* TODO: will need to use another href for id-ff 1.1 support */
306
304
        xpathObj = xmlXPathEvalExpression((xmlChar*)"//lib:AuthnRequest", xpathCtx);
307
305
 
308
 
        if (xpathObj == NULL)
 
306
        if (xpathObj == NULL) {
 
307
                xmlXPathFreeContext(xpathCtx);
309
308
                return critical_error(LASSO_PROFILE_ERROR_INVALID_MSG);
 
309
        }
310
310
 
311
311
        if (xpathObj->nodesetval == NULL || xpathObj->nodesetval->nodeNr == 0) {
 
312
                xmlXPathFreeContext(xpathCtx);
312
313
                xmlXPathFreeObject(xpathObj);
313
314
                return critical_error(LASSO_PROFILE_ERROR_INVALID_MSG);
314
315
        }
315
316
 
316
317
        authn_request = xmlCopyNode(xpathObj->nodesetval->nodeTab[0], 1);
 
318
        xmlXPathFreeContext(xpathCtx);
 
319
        xmlXPathFreeObject(xpathObj);
317
320
        xmlFreeDoc(doc);
 
321
        xpathCtx = NULL;
 
322
        xpathObj = NULL;
 
323
        doc = NULL;
318
324
 
319
325
        soap_envelope = xmlNewNode(NULL, (xmlChar*)"Envelope");
320
326
        xmlSetNs(soap_envelope, xmlNewNs(soap_envelope,
353
359
        LassoProfile *profile;
354
360
        LassoMessageFormat format;
355
361
 
356
 
        g_return_val_if_fail(LASSO_IS_LECP(lecp), -1);
357
 
        g_return_val_if_fail(response_msg!=NULL, -2);
 
362
        g_return_val_if_fail(LASSO_IS_LECP(lecp), LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
 
363
        g_return_val_if_fail(response_msg != NULL, LASSO_PARAM_ERROR_INVALID_VALUE);
358
364
 
359
365
        profile = LASSO_PROFILE(lecp);
360
366
 
367
373
 
368
374
        profile->response = g_object_ref(lecp->authnResponseEnvelope->AuthnResponse);
369
375
        if (profile->response == NULL) {
370
 
                message(G_LOG_LEVEL_CRITICAL, "AuthnResponse not found");
371
 
                return LASSO_ERROR_UNDEFINED;
 
376
                return LASSO_PROFILE_ERROR_MISSING_RESPONSE;
372
377
        }
373
378
 
374
379
        lecp->assertionConsumerServiceURL = g_strdup(
390
395
void
391
396
lasso_lecp_destroy(LassoLecp *lecp)
392
397
{
393
 
        g_object_unref(G_OBJECT(lecp));
 
398
        lasso_node_destroy(LASSO_NODE(lecp));
394
399
}
395
400
 
396
401
/*****************************************************************************/