diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-06-05 13:21:49 +0200 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-06-05 13:21:49 +0200 |
commit | fc1a8c08ef0235addf518e45dd26c8980288a8e2 (patch) | |
tree | adc08ecccc1b6fb76fe78ca50f48ac313d4db3a0 /src | |
parent | 6a8ff6f7fe858899a2f6418691b01120323a10d4 (diff) | |
download | gnunet-fc1a8c08ef0235addf518e45dd26c8980288a8e2.tar.gz gnunet-fc1a8c08ef0235addf518e45dd26c8980288a8e2.zip |
clang-format
Diffstat (limited to 'src')
-rw-r--r-- | src/reclaim/plugin_rest_reclaim.c | 293 |
1 files changed, 196 insertions, 97 deletions
diff --git a/src/reclaim/plugin_rest_reclaim.c b/src/reclaim/plugin_rest_reclaim.c index 9e57f4f46..1efd1f9ea 100644 --- a/src/reclaim/plugin_rest_reclaim.c +++ b/src/reclaim/plugin_rest_reclaim.c | |||
@@ -264,8 +264,10 @@ cleanup_handle (struct RequestHandle *handle) | |||
264 | GNUNET_free (handle->url); | 264 | GNUNET_free (handle->url); |
265 | if (NULL != handle->emsg) | 265 | if (NULL != handle->emsg) |
266 | GNUNET_free (handle->emsg); | 266 | GNUNET_free (handle->emsg); |
267 | if (NULL != handle->attr_list) { | 267 | if (NULL != handle->attr_list) |
268 | for (claim_entry = handle->attr_list->list_head; NULL != claim_entry;) { | 268 | { |
269 | for (claim_entry = handle->attr_list->list_head; NULL != claim_entry;) | ||
270 | { | ||
269 | claim_tmp = claim_entry; | 271 | claim_tmp = claim_entry; |
270 | claim_entry = claim_entry->next; | 272 | claim_entry = claim_entry->next; |
271 | GNUNET_free (claim_tmp->claim); | 273 | GNUNET_free (claim_tmp->claim); |
@@ -273,14 +275,16 @@ cleanup_handle (struct RequestHandle *handle) | |||
273 | } | 275 | } |
274 | GNUNET_free (handle->attr_list); | 276 | GNUNET_free (handle->attr_list); |
275 | } | 277 | } |
276 | for (ego_entry = handle->ego_head; NULL != ego_entry;) { | 278 | for (ego_entry = handle->ego_head; NULL != ego_entry;) |
279 | { | ||
277 | ego_tmp = ego_entry; | 280 | ego_tmp = ego_entry; |
278 | ego_entry = ego_entry->next; | 281 | ego_entry = ego_entry->next; |
279 | GNUNET_free (ego_tmp->identifier); | 282 | GNUNET_free (ego_tmp->identifier); |
280 | GNUNET_free (ego_tmp->keystring); | 283 | GNUNET_free (ego_tmp->keystring); |
281 | GNUNET_free (ego_tmp); | 284 | GNUNET_free (ego_tmp); |
282 | } | 285 | } |
283 | if (NULL != handle->attr_it) { | 286 | if (NULL != handle->attr_it) |
287 | { | ||
284 | GNUNET_free (handle->attr_it); | 288 | GNUNET_free (handle->attr_it); |
285 | } | 289 | } |
286 | GNUNET_free (handle); | 290 | GNUNET_free (handle); |
@@ -306,7 +310,8 @@ do_error (void *cls) | |||
306 | char *json_error; | 310 | char *json_error; |
307 | 311 | ||
308 | GNUNET_asprintf (&json_error, "{ \"error\" : \"%s\" }", handle->emsg); | 312 | GNUNET_asprintf (&json_error, "{ \"error\" : \"%s\" }", handle->emsg); |
309 | if (0 == handle->response_code) { | 313 | if (0 == handle->response_code) |
314 | { | ||
310 | handle->response_code = MHD_HTTP_BAD_REQUEST; | 315 | handle->response_code = MHD_HTTP_BAD_REQUEST; |
311 | } | 316 | } |
312 | resp = GNUNET_REST_create_response (json_error); | 317 | resp = GNUNET_REST_create_response (json_error); |
@@ -347,7 +352,8 @@ finished_cont (void *cls, int32_t success, const char *emsg) | |||
347 | struct MHD_Response *resp; | 352 | struct MHD_Response *resp; |
348 | 353 | ||
349 | resp = GNUNET_REST_create_response (emsg); | 354 | resp = GNUNET_REST_create_response (emsg); |
350 | if (GNUNET_OK != success) { | 355 | if (GNUNET_OK != success) |
356 | { | ||
351 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 357 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
352 | return; | 358 | return; |
353 | } | 359 | } |
@@ -405,13 +411,17 @@ ticket_collect (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket) | |||
405 | GNUNET_free (tmp); | 411 | GNUNET_free (tmp); |
406 | json_array_append (handle->resp_object, json_resource); | 412 | json_array_append (handle->resp_object, json_resource); |
407 | 413 | ||
408 | tmp = GNUNET_STRINGS_data_to_string_alloc ( | 414 | tmp = |
409 | &ticket->identity, sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); | 415 | GNUNET_STRINGS_data_to_string_alloc (&ticket->identity, |
416 | sizeof (struct | ||
417 | GNUNET_CRYPTO_EcdsaPublicKey)); | ||
410 | value = json_string (tmp); | 418 | value = json_string (tmp); |
411 | json_object_set_new (json_resource, "issuer", value); | 419 | json_object_set_new (json_resource, "issuer", value); |
412 | GNUNET_free (tmp); | 420 | GNUNET_free (tmp); |
413 | tmp = GNUNET_STRINGS_data_to_string_alloc ( | 421 | tmp = |
414 | &ticket->audience, sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); | 422 | GNUNET_STRINGS_data_to_string_alloc (&ticket->audience, |
423 | sizeof (struct | ||
424 | GNUNET_CRYPTO_EcdsaPublicKey)); | ||
415 | value = json_string (tmp); | 425 | value = json_string (tmp); |
416 | json_object_set_new (json_resource, "audience", value); | 426 | json_object_set_new (json_resource, "audience", value); |
417 | GNUNET_free (tmp); | 427 | GNUNET_free (tmp); |
@@ -432,16 +442,19 @@ ticket_collect (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket) | |||
432 | */ | 442 | */ |
433 | static void | 443 | static void |
434 | list_tickets_cont (struct GNUNET_REST_RequestHandle *con_handle, | 444 | list_tickets_cont (struct GNUNET_REST_RequestHandle *con_handle, |
435 | const char *url, void *cls) | 445 | const char *url, |
446 | void *cls) | ||
436 | { | 447 | { |
437 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key; | 448 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key; |
438 | struct RequestHandle *handle = cls; | 449 | struct RequestHandle *handle = cls; |
439 | struct EgoEntry *ego_entry; | 450 | struct EgoEntry *ego_entry; |
440 | char *identity; | 451 | char *identity; |
441 | 452 | ||
442 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Getting tickets for %s.\n", | 453 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
454 | "Getting tickets for %s.\n", | ||
443 | handle->url); | 455 | handle->url); |
444 | if (strlen (GNUNET_REST_API_NS_IDENTITY_TICKETS) >= strlen (handle->url)) { | 456 | if (strlen (GNUNET_REST_API_NS_IDENTITY_TICKETS) >= strlen (handle->url)) |
457 | { | ||
445 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n"); | 458 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n"); |
446 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 459 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
447 | return; | 460 | return; |
@@ -454,7 +467,8 @@ list_tickets_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
454 | break; | 467 | break; |
455 | handle->resp_object = json_array (); | 468 | handle->resp_object = json_array (); |
456 | 469 | ||
457 | if (NULL == ego_entry) { | 470 | if (NULL == ego_entry) |
471 | { | ||
458 | // Done | 472 | // Done |
459 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity); | 473 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity); |
460 | GNUNET_SCHEDULER_add_now (&return_response, handle); | 474 | GNUNET_SCHEDULER_add_now (&return_response, handle); |
@@ -462,15 +476,22 @@ list_tickets_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
462 | } | 476 | } |
463 | priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); | 477 | priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); |
464 | handle->idp = GNUNET_RECLAIM_connect (cfg); | 478 | handle->idp = GNUNET_RECLAIM_connect (cfg); |
465 | handle->ticket_it = GNUNET_RECLAIM_ticket_iteration_start ( | 479 | handle->ticket_it = |
466 | handle->idp, priv_key, &collect_error_cb, handle, &ticket_collect, handle, | 480 | GNUNET_RECLAIM_ticket_iteration_start (handle->idp, |
467 | &collect_finished_cb, handle); | 481 | priv_key, |
482 | &collect_error_cb, | ||
483 | handle, | ||
484 | &ticket_collect, | ||
485 | handle, | ||
486 | &collect_finished_cb, | ||
487 | handle); | ||
468 | } | 488 | } |
469 | 489 | ||
470 | 490 | ||
471 | static void | 491 | static void |
472 | add_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, | 492 | add_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, |
473 | const char *url, void *cls) | 493 | const char *url, |
494 | void *cls) | ||
474 | { | 495 | { |
475 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv; | 496 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv; |
476 | const char *identity; | 497 | const char *identity; |
@@ -481,12 +502,14 @@ add_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
481 | char term_data[handle->rest_handle->data_size + 1]; | 502 | char term_data[handle->rest_handle->data_size + 1]; |
482 | json_t *data_json; | 503 | json_t *data_json; |
483 | json_error_t err; | 504 | json_error_t err; |
484 | struct GNUNET_JSON_Specification attrspec[] = { | 505 | struct GNUNET_JSON_Specification attrspec[] = |
485 | GNUNET_RECLAIM_JSON_spec_claim (&attribute), GNUNET_JSON_spec_end ()}; | 506 | {GNUNET_RECLAIM_JSON_spec_claim (&attribute), GNUNET_JSON_spec_end ()}; |
486 | 507 | ||
487 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding an attribute for %s.\n", | 508 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
509 | "Adding an attribute for %s.\n", | ||
488 | handle->url); | 510 | handle->url); |
489 | if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) >= strlen (handle->url)) { | 511 | if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) >= strlen (handle->url)) |
512 | { | ||
490 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n"); | 513 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n"); |
491 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 514 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
492 | return; | 515 | return; |
@@ -498,26 +521,31 @@ add_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
498 | if (0 == strcmp (identity, ego_entry->identifier)) | 521 | if (0 == strcmp (identity, ego_entry->identifier)) |
499 | break; | 522 | break; |
500 | 523 | ||
501 | if (NULL == ego_entry) { | 524 | if (NULL == ego_entry) |
525 | { | ||
502 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Identity unknown (%s)\n", identity); | 526 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Identity unknown (%s)\n", identity); |
503 | return; | 527 | return; |
504 | } | 528 | } |
505 | identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); | 529 | identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); |
506 | 530 | ||
507 | if (0 >= handle->rest_handle->data_size) { | 531 | if (0 >= handle->rest_handle->data_size) |
532 | { | ||
508 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 533 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
509 | return; | 534 | return; |
510 | } | 535 | } |
511 | 536 | ||
512 | term_data[handle->rest_handle->data_size] = '\0'; | 537 | term_data[handle->rest_handle->data_size] = '\0'; |
513 | GNUNET_memcpy (term_data, handle->rest_handle->data, | 538 | GNUNET_memcpy (term_data, |
539 | handle->rest_handle->data, | ||
514 | handle->rest_handle->data_size); | 540 | handle->rest_handle->data_size); |
515 | data_json = json_loads (term_data, JSON_DECODE_ANY, &err); | 541 | data_json = json_loads (term_data, JSON_DECODE_ANY, &err); |
516 | GNUNET_assert (GNUNET_OK == | 542 | GNUNET_assert (GNUNET_OK == |
517 | GNUNET_JSON_parse (data_json, attrspec, NULL, NULL)); | 543 | GNUNET_JSON_parse (data_json, attrspec, NULL, NULL)); |
518 | json_decref (data_json); | 544 | json_decref (data_json); |
519 | if (NULL == attribute) { | 545 | if (NULL == attribute) |
520 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unable to parse attribute from %s\n", | 546 | { |
547 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
548 | "Unable to parse attribute from %s\n", | ||
521 | term_data); | 549 | term_data); |
522 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 550 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
523 | return; | 551 | return; |
@@ -530,8 +558,12 @@ add_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
530 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); | 558 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, UINT64_MAX); |
531 | handle->idp = GNUNET_RECLAIM_connect (cfg); | 559 | handle->idp = GNUNET_RECLAIM_connect (cfg); |
532 | exp = GNUNET_TIME_UNIT_HOURS; | 560 | exp = GNUNET_TIME_UNIT_HOURS; |
533 | handle->idp_op = GNUNET_RECLAIM_attribute_store ( | 561 | handle->idp_op = GNUNET_RECLAIM_attribute_store (handle->idp, |
534 | handle->idp, identity_priv, attribute, &exp, &finished_cont, handle); | 562 | identity_priv, |
563 | attribute, | ||
564 | &exp, | ||
565 | &finished_cont, | ||
566 | handle); | ||
535 | GNUNET_JSON_parse_free (attrspec); | 567 | GNUNET_JSON_parse_free (attrspec); |
536 | } | 568 | } |
537 | 569 | ||
@@ -541,7 +573,8 @@ add_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
541 | * | 573 | * |
542 | */ | 574 | */ |
543 | static void | 575 | static void |
544 | attr_collect (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | 576 | attr_collect (void *cls, |
577 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | ||
545 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) | 578 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) |
546 | { | 579 | { |
547 | struct RequestHandle *handle = cls; | 580 | struct RequestHandle *handle = cls; |
@@ -550,14 +583,16 @@ attr_collect (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | |||
550 | char *tmp_value; | 583 | char *tmp_value; |
551 | char *id_str; | 584 | char *id_str; |
552 | 585 | ||
553 | if ((NULL == attr->name) || (NULL == attr->data)) { | 586 | if ((NULL == attr->name) || (NULL == attr->data)) |
587 | { | ||
554 | GNUNET_RECLAIM_get_attributes_next (handle->attr_it); | 588 | GNUNET_RECLAIM_get_attributes_next (handle->attr_it); |
555 | return; | 589 | return; |
556 | } | 590 | } |
557 | 591 | ||
558 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute: %s\n", attr->name); | 592 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute: %s\n", attr->name); |
559 | 593 | ||
560 | tmp_value = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type, attr->data, | 594 | tmp_value = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type, |
595 | attr->data, | ||
561 | attr->data_size); | 596 | attr->data_size); |
562 | 597 | ||
563 | attr_obj = json_object (); | 598 | attr_obj = json_object (); |
@@ -583,16 +618,19 @@ attr_collect (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | |||
583 | */ | 618 | */ |
584 | static void | 619 | static void |
585 | list_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, | 620 | list_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, |
586 | const char *url, void *cls) | 621 | const char *url, |
622 | void *cls) | ||
587 | { | 623 | { |
588 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key; | 624 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key; |
589 | struct RequestHandle *handle = cls; | 625 | struct RequestHandle *handle = cls; |
590 | struct EgoEntry *ego_entry; | 626 | struct EgoEntry *ego_entry; |
591 | char *identity; | 627 | char *identity; |
592 | 628 | ||
593 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Getting attributes for %s.\n", | 629 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
630 | "Getting attributes for %s.\n", | ||
594 | handle->url); | 631 | handle->url); |
595 | if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) >= strlen (handle->url)) { | 632 | if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) >= strlen (handle->url)) |
633 | { | ||
596 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n"); | 634 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n"); |
597 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 635 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
598 | return; | 636 | return; |
@@ -606,7 +644,8 @@ list_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
606 | handle->resp_object = json_array (); | 644 | handle->resp_object = json_array (); |
607 | 645 | ||
608 | 646 | ||
609 | if (NULL == ego_entry) { | 647 | if (NULL == ego_entry) |
648 | { | ||
610 | // Done | 649 | // Done |
611 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity); | 650 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity); |
612 | GNUNET_SCHEDULER_add_now (&return_response, handle); | 651 | GNUNET_SCHEDULER_add_now (&return_response, handle); |
@@ -614,9 +653,14 @@ list_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
614 | } | 653 | } |
615 | priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); | 654 | priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); |
616 | handle->idp = GNUNET_RECLAIM_connect (cfg); | 655 | handle->idp = GNUNET_RECLAIM_connect (cfg); |
617 | handle->attr_it = GNUNET_RECLAIM_get_attributes_start ( | 656 | handle->attr_it = GNUNET_RECLAIM_get_attributes_start (handle->idp, |
618 | handle->idp, priv_key, &collect_error_cb, handle, &attr_collect, handle, | 657 | priv_key, |
619 | &collect_finished_cb, handle); | 658 | &collect_error_cb, |
659 | handle, | ||
660 | &attr_collect, | ||
661 | handle, | ||
662 | &collect_finished_cb, | ||
663 | handle); | ||
620 | } | 664 | } |
621 | 665 | ||
622 | 666 | ||
@@ -627,7 +671,8 @@ delete_finished_cb (void *cls, int32_t success, const char *emsg) | |||
627 | struct MHD_Response *resp; | 671 | struct MHD_Response *resp; |
628 | 672 | ||
629 | resp = GNUNET_REST_create_response (emsg); | 673 | resp = GNUNET_REST_create_response (emsg); |
630 | if (GNUNET_OK != success) { | 674 | if (GNUNET_OK != success) |
675 | { | ||
631 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 676 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
632 | return; | 677 | return; |
633 | } | 678 | } |
@@ -645,7 +690,8 @@ delete_finished_cb (void *cls, int32_t success, const char *emsg) | |||
645 | */ | 690 | */ |
646 | static void | 691 | static void |
647 | delete_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, | 692 | delete_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, |
648 | const char *url, void *cls) | 693 | const char *url, |
694 | void *cls) | ||
649 | { | 695 | { |
650 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key; | 696 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key; |
651 | struct RequestHandle *handle = cls; | 697 | struct RequestHandle *handle = cls; |
@@ -656,7 +702,8 @@ delete_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
656 | char *id; | 702 | char *id; |
657 | 703 | ||
658 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting attributes.\n"); | 704 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting attributes.\n"); |
659 | if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) >= strlen (handle->url)) { | 705 | if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) >= strlen (handle->url)) |
706 | { | ||
660 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n"); | 707 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n"); |
661 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 708 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
662 | return; | 709 | return; |
@@ -665,7 +712,8 @@ delete_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
665 | strdup (handle->url + strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) + 1); | 712 | strdup (handle->url + strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) + 1); |
666 | identity = strtok (identity_id_str, "/"); | 713 | identity = strtok (identity_id_str, "/"); |
667 | id = strtok (NULL, "/"); | 714 | id = strtok (NULL, "/"); |
668 | if ((NULL == identity) || (NULL == id)) { | 715 | if ((NULL == identity) || (NULL == id)) |
716 | { | ||
669 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Malformed request.\n"); | 717 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Malformed request.\n"); |
670 | GNUNET_free (identity_id_str); | 718 | GNUNET_free (identity_id_str); |
671 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 719 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
@@ -677,7 +725,8 @@ delete_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
677 | if (0 == strcmp (identity, ego_entry->identifier)) | 725 | if (0 == strcmp (identity, ego_entry->identifier)) |
678 | break; | 726 | break; |
679 | handle->resp_object = json_array (); | 727 | handle->resp_object = json_array (); |
680 | if (NULL == ego_entry) { | 728 | if (NULL == ego_entry) |
729 | { | ||
681 | // Done | 730 | // Done |
682 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity); | 731 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity); |
683 | GNUNET_free (identity_id_str); | 732 | GNUNET_free (identity_id_str); |
@@ -689,15 +738,19 @@ delete_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
689 | memset (&attr, 0, sizeof (struct GNUNET_RECLAIM_ATTRIBUTE_Claim)); | 738 | memset (&attr, 0, sizeof (struct GNUNET_RECLAIM_ATTRIBUTE_Claim)); |
690 | GNUNET_STRINGS_string_to_data (id, strlen (id), &attr.id, sizeof (uint64_t)); | 739 | GNUNET_STRINGS_string_to_data (id, strlen (id), &attr.id, sizeof (uint64_t)); |
691 | attr.name = ""; | 740 | attr.name = ""; |
692 | handle->idp_op = GNUNET_RECLAIM_attribute_delete ( | 741 | handle->idp_op = GNUNET_RECLAIM_attribute_delete (handle->idp, |
693 | handle->idp, priv_key, &attr, &delete_finished_cb, handle); | 742 | priv_key, |
743 | &attr, | ||
744 | &delete_finished_cb, | ||
745 | handle); | ||
694 | GNUNET_free (identity_id_str); | 746 | GNUNET_free (identity_id_str); |
695 | } | 747 | } |
696 | 748 | ||
697 | 749 | ||
698 | static void | 750 | static void |
699 | revoke_ticket_cont (struct GNUNET_REST_RequestHandle *con_handle, | 751 | revoke_ticket_cont (struct GNUNET_REST_RequestHandle *con_handle, |
700 | const char *url, void *cls) | 752 | const char *url, |
753 | void *cls) | ||
701 | { | 754 | { |
702 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv; | 755 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv; |
703 | struct RequestHandle *handle = cls; | 756 | struct RequestHandle *handle = cls; |
@@ -707,19 +760,22 @@ revoke_ticket_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
707 | char term_data[handle->rest_handle->data_size + 1]; | 760 | char term_data[handle->rest_handle->data_size + 1]; |
708 | json_t *data_json; | 761 | json_t *data_json; |
709 | json_error_t err; | 762 | json_error_t err; |
710 | struct GNUNET_JSON_Specification tktspec[] = { | 763 | struct GNUNET_JSON_Specification tktspec[] = |
711 | GNUNET_RECLAIM_JSON_spec_ticket (&ticket), GNUNET_JSON_spec_end ()}; | 764 | {GNUNET_RECLAIM_JSON_spec_ticket (&ticket), GNUNET_JSON_spec_end ()}; |
712 | 765 | ||
713 | if (0 >= handle->rest_handle->data_size) { | 766 | if (0 >= handle->rest_handle->data_size) |
767 | { | ||
714 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 768 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
715 | return; | 769 | return; |
716 | } | 770 | } |
717 | 771 | ||
718 | term_data[handle->rest_handle->data_size] = '\0'; | 772 | term_data[handle->rest_handle->data_size] = '\0'; |
719 | GNUNET_memcpy (term_data, handle->rest_handle->data, | 773 | GNUNET_memcpy (term_data, |
774 | handle->rest_handle->data, | ||
720 | handle->rest_handle->data_size); | 775 | handle->rest_handle->data_size); |
721 | data_json = json_loads (term_data, JSON_DECODE_ANY, &err); | 776 | data_json = json_loads (term_data, JSON_DECODE_ANY, &err); |
722 | if (GNUNET_OK != GNUNET_JSON_parse (data_json, tktspec, NULL, NULL)) { | 777 | if (GNUNET_OK != GNUNET_JSON_parse (data_json, tktspec, NULL, NULL)) |
778 | { | ||
723 | handle->emsg = GNUNET_strdup ("Not a ticket!\n"); | 779 | handle->emsg = GNUNET_strdup ("Not a ticket!\n"); |
724 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 780 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
725 | GNUNET_JSON_parse_free (tktspec); | 781 | GNUNET_JSON_parse_free (tktspec); |
@@ -727,21 +783,26 @@ revoke_ticket_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
727 | return; | 783 | return; |
728 | } | 784 | } |
729 | json_decref (data_json); | 785 | json_decref (data_json); |
730 | if (NULL == ticket) { | 786 | if (NULL == ticket) |
731 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Unable to parse ticket from %s\n", | 787 | { |
788 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
789 | "Unable to parse ticket from %s\n", | ||
732 | term_data); | 790 | term_data); |
733 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 791 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
734 | return; | 792 | return; |
735 | } | 793 | } |
736 | 794 | ||
737 | for (ego_entry = handle->ego_head; NULL != ego_entry; | 795 | for (ego_entry = handle->ego_head; NULL != ego_entry; |
738 | ego_entry = ego_entry->next) { | 796 | ego_entry = ego_entry->next) |
797 | { | ||
739 | GNUNET_IDENTITY_ego_get_public_key (ego_entry->ego, &tmp_pk); | 798 | GNUNET_IDENTITY_ego_get_public_key (ego_entry->ego, &tmp_pk); |
740 | if (0 == memcmp (&ticket->identity, &tmp_pk, | 799 | if (0 == memcmp (&ticket->identity, |
800 | &tmp_pk, | ||
741 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))) | 801 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))) |
742 | break; | 802 | break; |
743 | } | 803 | } |
744 | if (NULL == ego_entry) { | 804 | if (NULL == ego_entry) |
805 | { | ||
745 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Identity unknown\n"); | 806 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Identity unknown\n"); |
746 | GNUNET_JSON_parse_free (tktspec); | 807 | GNUNET_JSON_parse_free (tktspec); |
747 | return; | 808 | return; |
@@ -749,29 +810,37 @@ revoke_ticket_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
749 | identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); | 810 | identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); |
750 | 811 | ||
751 | handle->idp = GNUNET_RECLAIM_connect (cfg); | 812 | handle->idp = GNUNET_RECLAIM_connect (cfg); |
752 | handle->idp_op = GNUNET_RECLAIM_ticket_revoke ( | 813 | handle->idp_op = GNUNET_RECLAIM_ticket_revoke (handle->idp, |
753 | handle->idp, identity_priv, ticket, &finished_cont, handle); | 814 | identity_priv, |
815 | ticket, | ||
816 | &finished_cont, | ||
817 | handle); | ||
754 | GNUNET_JSON_parse_free (tktspec); | 818 | GNUNET_JSON_parse_free (tktspec); |
755 | } | 819 | } |
756 | 820 | ||
757 | static void | 821 | static void |
758 | consume_cont (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | 822 | consume_cont (void *cls, |
823 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | ||
759 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) | 824 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) |
760 | { | 825 | { |
761 | struct RequestHandle *handle = cls; | 826 | struct RequestHandle *handle = cls; |
762 | char *val_str; | 827 | char *val_str; |
763 | json_t *value; | 828 | json_t *value; |
764 | 829 | ||
765 | if (NULL == identity) { | 830 | if (NULL == identity) |
831 | { | ||
766 | GNUNET_SCHEDULER_add_now (&return_response, handle); | 832 | GNUNET_SCHEDULER_add_now (&return_response, handle); |
767 | return; | 833 | return; |
768 | } | 834 | } |
769 | 835 | ||
770 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute: %s\n", attr->name); | 836 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute: %s\n", attr->name); |
771 | val_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type, attr->data, | 837 | val_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type, |
838 | attr->data, | ||
772 | attr->data_size); | 839 | attr->data_size); |
773 | if (NULL == val_str) { | 840 | if (NULL == val_str) |
774 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to parse value for: %s\n", | 841 | { |
842 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
843 | "Failed to parse value for: %s\n", | ||
775 | attr->name); | 844 | attr->name); |
776 | return; | 845 | return; |
777 | } | 846 | } |
@@ -783,7 +852,8 @@ consume_cont (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | |||
783 | 852 | ||
784 | static void | 853 | static void |
785 | consume_ticket_cont (struct GNUNET_REST_RequestHandle *con_handle, | 854 | consume_ticket_cont (struct GNUNET_REST_RequestHandle *con_handle, |
786 | const char *url, void *cls) | 855 | const char *url, |
856 | void *cls) | ||
787 | { | 857 | { |
788 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv; | 858 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv; |
789 | struct RequestHandle *handle = cls; | 859 | struct RequestHandle *handle = cls; |
@@ -793,25 +863,30 @@ consume_ticket_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
793 | char term_data[handle->rest_handle->data_size + 1]; | 863 | char term_data[handle->rest_handle->data_size + 1]; |
794 | json_t *data_json; | 864 | json_t *data_json; |
795 | json_error_t err; | 865 | json_error_t err; |
796 | struct GNUNET_JSON_Specification tktspec[] = { | 866 | struct GNUNET_JSON_Specification tktspec[] = |
797 | GNUNET_RECLAIM_JSON_spec_ticket (&ticket), GNUNET_JSON_spec_end ()}; | 867 | {GNUNET_RECLAIM_JSON_spec_ticket (&ticket), GNUNET_JSON_spec_end ()}; |
798 | 868 | ||
799 | if (0 >= handle->rest_handle->data_size) { | 869 | if (0 >= handle->rest_handle->data_size) |
870 | { | ||
800 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 871 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
801 | return; | 872 | return; |
802 | } | 873 | } |
803 | 874 | ||
804 | term_data[handle->rest_handle->data_size] = '\0'; | 875 | term_data[handle->rest_handle->data_size] = '\0'; |
805 | GNUNET_memcpy (term_data, handle->rest_handle->data, | 876 | GNUNET_memcpy (term_data, |
877 | handle->rest_handle->data, | ||
806 | handle->rest_handle->data_size); | 878 | handle->rest_handle->data_size); |
807 | data_json = json_loads (term_data, JSON_DECODE_ANY, &err); | 879 | data_json = json_loads (term_data, JSON_DECODE_ANY, &err); |
808 | if (NULL == data_json) { | 880 | if (NULL == data_json) |
881 | { | ||
809 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 882 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
810 | "Unable to parse JSON Object from %s\n", term_data); | 883 | "Unable to parse JSON Object from %s\n", |
884 | term_data); | ||
811 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 885 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
812 | return; | 886 | return; |
813 | } | 887 | } |
814 | if (GNUNET_OK != GNUNET_JSON_parse (data_json, tktspec, NULL, NULL)) { | 888 | if (GNUNET_OK != GNUNET_JSON_parse (data_json, tktspec, NULL, NULL)) |
889 | { | ||
815 | handle->emsg = GNUNET_strdup ("Not a ticket!\n"); | 890 | handle->emsg = GNUNET_strdup ("Not a ticket!\n"); |
816 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 891 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
817 | GNUNET_JSON_parse_free (tktspec); | 892 | GNUNET_JSON_parse_free (tktspec); |
@@ -819,13 +894,16 @@ consume_ticket_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
819 | return; | 894 | return; |
820 | } | 895 | } |
821 | for (ego_entry = handle->ego_head; NULL != ego_entry; | 896 | for (ego_entry = handle->ego_head; NULL != ego_entry; |
822 | ego_entry = ego_entry->next) { | 897 | ego_entry = ego_entry->next) |
898 | { | ||
823 | GNUNET_IDENTITY_ego_get_public_key (ego_entry->ego, &tmp_pk); | 899 | GNUNET_IDENTITY_ego_get_public_key (ego_entry->ego, &tmp_pk); |
824 | if (0 == memcmp (&ticket->audience, &tmp_pk, | 900 | if (0 == memcmp (&ticket->audience, |
901 | &tmp_pk, | ||
825 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))) | 902 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))) |
826 | break; | 903 | break; |
827 | } | 904 | } |
828 | if (NULL == ego_entry) { | 905 | if (NULL == ego_entry) |
906 | { | ||
829 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Identity unknown\n"); | 907 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Identity unknown\n"); |
830 | GNUNET_JSON_parse_free (tktspec); | 908 | GNUNET_JSON_parse_free (tktspec); |
831 | return; | 909 | return; |
@@ -833,8 +911,11 @@ consume_ticket_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
833 | identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); | 911 | identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); |
834 | handle->resp_object = json_object (); | 912 | handle->resp_object = json_object (); |
835 | handle->idp = GNUNET_RECLAIM_connect (cfg); | 913 | handle->idp = GNUNET_RECLAIM_connect (cfg); |
836 | handle->idp_op = GNUNET_RECLAIM_ticket_consume ( | 914 | handle->idp_op = GNUNET_RECLAIM_ticket_consume (handle->idp, |
837 | handle->idp, identity_priv, ticket, &consume_cont, handle); | 915 | identity_priv, |
916 | ticket, | ||
917 | &consume_cont, | ||
918 | handle); | ||
838 | GNUNET_JSON_parse_free (tktspec); | 919 | GNUNET_JSON_parse_free (tktspec); |
839 | } | 920 | } |
840 | 921 | ||
@@ -847,7 +928,8 @@ consume_ticket_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
847 | * @param cls the RequestHandle | 928 | * @param cls the RequestHandle |
848 | */ | 929 | */ |
849 | static void | 930 | static void |
850 | options_cont (struct GNUNET_REST_RequestHandle *con_handle, const char *url, | 931 | options_cont (struct GNUNET_REST_RequestHandle *con_handle, |
932 | const char *url, | ||
851 | void *cls) | 933 | void *cls) |
852 | { | 934 | { |
853 | struct MHD_Response *resp; | 935 | struct MHD_Response *resp; |
@@ -870,24 +952,31 @@ static void | |||
870 | init_cont (struct RequestHandle *handle) | 952 | init_cont (struct RequestHandle *handle) |
871 | { | 953 | { |
872 | struct GNUNET_REST_RequestHandlerError err; | 954 | struct GNUNET_REST_RequestHandlerError err; |
873 | static const struct GNUNET_REST_RequestHandler handlers[] = { | 955 | static const struct GNUNET_REST_RequestHandler handlers[] = |
874 | {MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, | 956 | {{MHD_HTTP_METHOD_GET, |
957 | GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, | ||
875 | &list_attribute_cont}, | 958 | &list_attribute_cont}, |
876 | {MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, | 959 | {MHD_HTTP_METHOD_POST, |
960 | GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, | ||
877 | &add_attribute_cont}, | 961 | &add_attribute_cont}, |
878 | {MHD_HTTP_METHOD_DELETE, GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, | 962 | {MHD_HTTP_METHOD_DELETE, |
963 | GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, | ||
879 | &delete_attribute_cont}, | 964 | &delete_attribute_cont}, |
880 | {MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY_TICKETS, | 965 | {MHD_HTTP_METHOD_GET, |
966 | GNUNET_REST_API_NS_IDENTITY_TICKETS, | ||
881 | &list_tickets_cont}, | 967 | &list_tickets_cont}, |
882 | {MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_IDENTITY_REVOKE, | 968 | {MHD_HTTP_METHOD_POST, |
969 | GNUNET_REST_API_NS_IDENTITY_REVOKE, | ||
883 | &revoke_ticket_cont}, | 970 | &revoke_ticket_cont}, |
884 | {MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_IDENTITY_CONSUME, | 971 | {MHD_HTTP_METHOD_POST, |
972 | GNUNET_REST_API_NS_IDENTITY_CONSUME, | ||
885 | &consume_ticket_cont}, | 973 | &consume_ticket_cont}, |
886 | {MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_RECLAIM, &options_cont}, | 974 | {MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_RECLAIM, &options_cont}, |
887 | GNUNET_REST_HANDLER_END}; | 975 | GNUNET_REST_HANDLER_END}; |
888 | 976 | ||
889 | if (GNUNET_NO == GNUNET_REST_handle_request (handle->rest_handle, handlers, | 977 | if (GNUNET_NO == |
890 | &err, handle)) { | 978 | GNUNET_REST_handle_request (handle->rest_handle, handlers, &err, handle)) |
979 | { | ||
891 | handle->response_code = err.error_code; | 980 | handle->response_code = err.error_code; |
892 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 981 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
893 | } | 982 | } |
@@ -927,32 +1016,38 @@ init_cont (struct RequestHandle *handle) | |||
927 | * must thus no longer be used | 1016 | * must thus no longer be used |
928 | */ | 1017 | */ |
929 | static void | 1018 | static void |
930 | list_ego (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, | 1019 | list_ego (void *cls, |
1020 | struct GNUNET_IDENTITY_Ego *ego, | ||
1021 | void **ctx, | ||
931 | const char *identifier) | 1022 | const char *identifier) |
932 | { | 1023 | { |
933 | struct RequestHandle *handle = cls; | 1024 | struct RequestHandle *handle = cls; |
934 | struct EgoEntry *ego_entry; | 1025 | struct EgoEntry *ego_entry; |
935 | struct GNUNET_CRYPTO_EcdsaPublicKey pk; | 1026 | struct GNUNET_CRYPTO_EcdsaPublicKey pk; |
936 | 1027 | ||
937 | if ((NULL == ego) && (ID_REST_STATE_INIT == handle->state)) { | 1028 | if ((NULL == ego) && (ID_REST_STATE_INIT == handle->state)) |
1029 | { | ||
938 | handle->state = ID_REST_STATE_POST_INIT; | 1030 | handle->state = ID_REST_STATE_POST_INIT; |
939 | init_cont (handle); | 1031 | init_cont (handle); |
940 | return; | 1032 | return; |
941 | } | 1033 | } |
942 | if (ID_REST_STATE_INIT == handle->state) { | 1034 | if (ID_REST_STATE_INIT == handle->state) |
1035 | { | ||
943 | ego_entry = GNUNET_new (struct EgoEntry); | 1036 | ego_entry = GNUNET_new (struct EgoEntry); |
944 | GNUNET_IDENTITY_ego_get_public_key (ego, &pk); | 1037 | GNUNET_IDENTITY_ego_get_public_key (ego, &pk); |
945 | ego_entry->keystring = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pk); | 1038 | ego_entry->keystring = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pk); |
946 | ego_entry->ego = ego; | 1039 | ego_entry->ego = ego; |
947 | ego_entry->identifier = GNUNET_strdup (identifier); | 1040 | ego_entry->identifier = GNUNET_strdup (identifier); |
948 | GNUNET_CONTAINER_DLL_insert_tail (handle->ego_head, handle->ego_tail, | 1041 | GNUNET_CONTAINER_DLL_insert_tail (handle->ego_head, |
1042 | handle->ego_tail, | ||
949 | ego_entry); | 1043 | ego_entry); |
950 | } | 1044 | } |
951 | } | 1045 | } |
952 | 1046 | ||
953 | static void | 1047 | static void |
954 | rest_identity_process_request (struct GNUNET_REST_RequestHandle *rest_handle, | 1048 | rest_identity_process_request (struct GNUNET_REST_RequestHandle *rest_handle, |
955 | GNUNET_REST_ResultProcessor proc, void *proc_cls) | 1049 | GNUNET_REST_ResultProcessor proc, |
1050 | void *proc_cls) | ||
956 | { | 1051 | { |
957 | struct RequestHandle *handle = GNUNET_new (struct RequestHandle); | 1052 | struct RequestHandle *handle = GNUNET_new (struct RequestHandle); |
958 | handle->response_code = 0; | 1053 | handle->response_code = 0; |
@@ -993,9 +1088,13 @@ libgnunet_plugin_rest_reclaim_init (void *cls) | |||
993 | api->cls = &plugin; | 1088 | api->cls = &plugin; |
994 | api->name = GNUNET_REST_API_NS_RECLAIM; | 1089 | api->name = GNUNET_REST_API_NS_RECLAIM; |
995 | api->process_request = &rest_identity_process_request; | 1090 | api->process_request = &rest_identity_process_request; |
996 | GNUNET_asprintf (&allow_methods, "%s, %s, %s, %s, %s", MHD_HTTP_METHOD_GET, | 1091 | GNUNET_asprintf (&allow_methods, |
997 | MHD_HTTP_METHOD_POST, MHD_HTTP_METHOD_PUT, | 1092 | "%s, %s, %s, %s, %s", |
998 | MHD_HTTP_METHOD_DELETE, MHD_HTTP_METHOD_OPTIONS); | 1093 | MHD_HTTP_METHOD_GET, |
1094 | MHD_HTTP_METHOD_POST, | ||
1095 | MHD_HTTP_METHOD_PUT, | ||
1096 | MHD_HTTP_METHOD_DELETE, | ||
1097 | MHD_HTTP_METHOD_OPTIONS); | ||
999 | 1098 | ||
1000 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1099 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1001 | _ ("Identity Provider REST API initialized\n")); | 1100 | _ ("Identity Provider REST API initialized\n")); |