aboutsummaryrefslogtreecommitdiff
path: root/src/reclaim/plugin_rest_reclaim.c
diff options
context:
space:
mode:
authorMarkus Voggenreiter <Markus.Voggenreiter@tum.de>2019-10-15 09:32:16 +0200
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2020-01-13 13:31:02 +0100
commit0def2d57eabbf00947ede47b0e968c0a395ace50 (patch)
treeb93af20c076aa365df68356fa107d1689d918a8a /src/reclaim/plugin_rest_reclaim.c
parent2c65283b0bd97a8719f4c71aee8cc091a491129a (diff)
downloadgnunet-0def2d57eabbf00947ede47b0e968c0a395ace50.tar.gz
gnunet-0def2d57eabbf00947ede47b0e968c0a395ace50.zip
Delete Attestation via Service
Diffstat (limited to 'src/reclaim/plugin_rest_reclaim.c')
-rw-r--r--src/reclaim/plugin_rest_reclaim.c64
1 files changed, 60 insertions, 4 deletions
diff --git a/src/reclaim/plugin_rest_reclaim.c b/src/reclaim/plugin_rest_reclaim.c
index 9290925b8..b847b773c 100644
--- a/src/reclaim/plugin_rest_reclaim.c
+++ b/src/reclaim/plugin_rest_reclaim.c
@@ -546,15 +546,71 @@ list_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle,
546 return; 546 return;
547} 547}
548 548
549/*WIP*/ 549/**
550 * Deletes attestation from an identity
551 *
552 * @param con_handle the connection handle
553 * @param url the url
554 * @param cls the RequestHandle
555 */
550static void 556static void
551delete_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle, 557delete_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle,
552 const char *url, 558 const char *url,
553 void *cls) 559 void *cls)
554{ 560{
555 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Deleting Attestations not supported\n"); 561 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key;
556 GNUNET_SCHEDULER_add_now (&do_error, cls); 562 struct RequestHandle *handle = cls;
557 return; 563 struct GNUNET_RECLAIM_ATTESTATION_Claim attr;
564 struct EgoEntry *ego_entry;
565 char *identity_id_str;
566 char *identity;
567 char *id;
568
569 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting attestation.\n");
570 if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) >= strlen (
571 handle->url))
572 {
573 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
574 GNUNET_SCHEDULER_add_now (&do_error, handle);
575 return;
576 }
577 identity_id_str =
578 strdup (handle->url + strlen (
579 GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) + 1);
580 identity = strtok (identity_id_str, "/");
581 id = strtok (NULL, "/");
582 if ((NULL == identity) || (NULL == id))
583 {
584 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Malformed request.\n");
585 GNUNET_free (identity_id_str);
586 GNUNET_SCHEDULER_add_now (&do_error, handle);
587 return;
588 }
589
590 for (ego_entry = handle->ego_head; NULL != ego_entry;
591 ego_entry = ego_entry->next)
592 if (0 == strcmp (identity, ego_entry->identifier))
593 break;
594 handle->resp_object = json_array ();
595 if (NULL == ego_entry)
596 {
597 // Done
598 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
599 GNUNET_free (identity_id_str);
600 GNUNET_SCHEDULER_add_now (&return_response, handle);
601 return;
602 }
603 priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
604 handle->idp = GNUNET_RECLAIM_connect (cfg);
605 memset (&attr, 0, sizeof(struct GNUNET_RECLAIM_ATTESTATION_Claim));
606 GNUNET_STRINGS_string_to_data (id, strlen (id), &attr.id, sizeof(uint64_t));
607 attr.name = "";
608 handle->idp_op = GNUNET_RECLAIM_attestation_delete (handle->idp,
609 priv_key,
610 &attr,
611 &delete_finished_cb,
612 handle);
613 GNUNET_free (identity_id_str);
558} 614}
559 615
560/** 616/**