diff options
Diffstat (limited to 'src/identity-provider/plugin_rest_identity_provider.c')
-rw-r--r-- | src/identity-provider/plugin_rest_identity_provider.c | 60 |
1 files changed, 43 insertions, 17 deletions
diff --git a/src/identity-provider/plugin_rest_identity_provider.c b/src/identity-provider/plugin_rest_identity_provider.c index b104950ba..376110a6d 100644 --- a/src/identity-provider/plugin_rest_identity_provider.c +++ b/src/identity-provider/plugin_rest_identity_provider.c | |||
@@ -248,7 +248,7 @@ struct RequestHandle | |||
248 | /** | 248 | /** |
249 | * ID of a task associated with the resolution process. | 249 | * ID of a task associated with the resolution process. |
250 | */ | 250 | */ |
251 | struct GNUNET_SCHEDULER_Task * timeout_task; | 251 | struct GNUNET_SCHEDULER_Task *timeout_task; |
252 | 252 | ||
253 | /** | 253 | /** |
254 | * The plugin result processor | 254 | * The plugin result processor |
@@ -321,9 +321,9 @@ cleanup_handle (struct RequestHandle *handle) | |||
321 | 321 | ||
322 | 322 | ||
323 | /** | 323 | /** |
324 | * Task run on shutdown. Cleans up everything. | 324 | * Task run on error, sends error message. Cleans up everything. |
325 | * | 325 | * |
326 | * @param cls unused | 326 | * @param cls the `struct RequestHandle` |
327 | */ | 327 | */ |
328 | static void | 328 | static void |
329 | do_error (void *cls) | 329 | do_error (void *cls) |
@@ -342,6 +342,21 @@ do_error (void *cls) | |||
342 | } | 342 | } |
343 | 343 | ||
344 | /** | 344 | /** |
345 | * Task run on timeout, sends error message. Cleans up everything. | ||
346 | * | ||
347 | * @param cls the `struct RequestHandle` | ||
348 | */ | ||
349 | static void | ||
350 | do_timeout (void *cls) | ||
351 | { | ||
352 | struct RequestHandle *handle = cls; | ||
353 | |||
354 | handle->timeout_task = NULL; | ||
355 | do_error (handle); | ||
356 | } | ||
357 | |||
358 | |||
359 | /** | ||
345 | * Task run on shutdown. Cleans up everything. | 360 | * Task run on shutdown. Cleans up everything. |
346 | * | 361 | * |
347 | * @param cls unused | 362 | * @param cls unused |
@@ -350,7 +365,8 @@ static void | |||
350 | do_cleanup_handle_delayed (void *cls) | 365 | do_cleanup_handle_delayed (void *cls) |
351 | { | 366 | { |
352 | struct RequestHandle *handle = cls; | 367 | struct RequestHandle *handle = cls; |
353 | cleanup_handle(handle); | 368 | |
369 | cleanup_handle (handle); | ||
354 | } | 370 | } |
355 | 371 | ||
356 | 372 | ||
@@ -406,10 +422,9 @@ token_creat_cont (void *cls, | |||
406 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); | 422 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); |
407 | GNUNET_free (result_str); | 423 | GNUNET_free (result_str); |
408 | GNUNET_SCHEDULER_add_now (&do_cleanup_handle_delayed, handle); | 424 | GNUNET_SCHEDULER_add_now (&do_cleanup_handle_delayed, handle); |
409 | |||
410 | |||
411 | } | 425 | } |
412 | 426 | ||
427 | |||
413 | /** | 428 | /** |
414 | * Continueationf for token issue request | 429 | * Continueationf for token issue request |
415 | * | 430 | * |
@@ -459,7 +474,8 @@ issue_token_cont (struct RestConnectionDataHandle *con, | |||
459 | GNUNET_CONTAINER_multihashmap_contains (handle->conndata_handle->url_param_map, | 474 | GNUNET_CONTAINER_multihashmap_contains (handle->conndata_handle->url_param_map, |
460 | &key) ) | 475 | &key) ) |
461 | { | 476 | { |
462 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Issuer not found\n"); | 477 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
478 | "Issuer not found\n"); | ||
463 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 479 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
464 | return; | 480 | return; |
465 | } | 481 | } |
@@ -468,7 +484,9 @@ issue_token_cont (struct RestConnectionDataHandle *con, | |||
468 | if (NULL == ego_val) | 484 | if (NULL == ego_val) |
469 | { | 485 | { |
470 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 486 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
471 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Ego invalid: %s\n", ego_val); | 487 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
488 | "Ego invalid: %s\n", | ||
489 | ego_val); | ||
472 | return; | 490 | return; |
473 | } | 491 | } |
474 | for (ego_entry = handle->ego_head; | 492 | for (ego_entry = handle->ego_head; |
@@ -480,13 +498,18 @@ issue_token_cont (struct RestConnectionDataHandle *con, | |||
480 | egoname = ego_entry->identifier; | 498 | egoname = ego_entry->identifier; |
481 | break; | 499 | break; |
482 | } | 500 | } |
483 | if (NULL == egoname || NULL == ego_entry) | 501 | if ( (NULL == egoname) || |
502 | (NULL == ego_entry) ) | ||
484 | { | 503 | { |
485 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Ego not found: %s\n", ego_val); | 504 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
505 | "Ego not found: %s\n", | ||
506 | ego_val); | ||
486 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 507 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
487 | return; | 508 | return; |
488 | } | 509 | } |
489 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego to issue token for: %s\n", egoname); | 510 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
511 | "Ego to issue token for: %s\n", | ||
512 | egoname); | ||
490 | 513 | ||
491 | 514 | ||
492 | //Meta info | 515 | //Meta info |
@@ -516,13 +539,16 @@ issue_token_cont (struct RestConnectionDataHandle *con, | |||
516 | GNUNET_CONTAINER_multihashmap_contains (handle->conndata_handle->url_param_map, | 539 | GNUNET_CONTAINER_multihashmap_contains (handle->conndata_handle->url_param_map, |
517 | &key) ) | 540 | &key) ) |
518 | { | 541 | { |
519 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Audience missing!\n"); | 542 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
543 | "Audience missing!\n"); | ||
520 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 544 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
521 | return; | 545 | return; |
522 | } | 546 | } |
523 | audience = GNUNET_CONTAINER_multihashmap_get (handle->conndata_handle->url_param_map, | 547 | audience = GNUNET_CONTAINER_multihashmap_get (handle->conndata_handle->url_param_map, |
524 | &key); | 548 | &key); |
525 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Audience to issue token for: %s\n", audience); | 549 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
550 | "Audience to issue token for: %s\n", | ||
551 | audience); | ||
526 | 552 | ||
527 | priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); | 553 | priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); |
528 | GNUNET_IDENTITY_ego_get_public_key (ego_entry->ego, | 554 | GNUNET_IDENTITY_ego_get_public_key (ego_entry->ego, |
@@ -547,7 +573,9 @@ issue_token_cont (struct RestConnectionDataHandle *con, | |||
547 | } | 573 | } |
548 | nonce_str = GNUNET_CONTAINER_multihashmap_get (handle->conndata_handle->url_param_map, | 574 | nonce_str = GNUNET_CONTAINER_multihashmap_get (handle->conndata_handle->url_param_map, |
549 | &key); | 575 | &key); |
550 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Request nonce: %s\n", nonce_str); | 576 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
577 | "Request nonce: %s\n", | ||
578 | nonce_str); | ||
551 | sscanf (nonce_str, "%"SCNu64, &nonce); | 579 | sscanf (nonce_str, "%"SCNu64, &nonce); |
552 | 580 | ||
553 | //Get expiration for token from URL parameter | 581 | //Get expiration for token from URL parameter |
@@ -1048,10 +1076,8 @@ rest_identity_process_request(struct RestConnectionDataHandle *conndata_handle, | |||
1048 | handle); | 1076 | handle); |
1049 | handle->timeout_task = | 1077 | handle->timeout_task = |
1050 | GNUNET_SCHEDULER_add_delayed (handle->timeout, | 1078 | GNUNET_SCHEDULER_add_delayed (handle->timeout, |
1051 | &do_error, | 1079 | &do_timeout, |
1052 | handle); | 1080 | handle); |
1053 | |||
1054 | |||
1055 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1081 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1056 | "Connected\n"); | 1082 | "Connected\n"); |
1057 | } | 1083 | } |