aboutsummaryrefslogtreecommitdiff
path: root/src/reclaim
diff options
context:
space:
mode:
authorMarkus Voggenreiter <Markus.Voggenreiter@tum.de>2019-10-12 22:26:24 +0200
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2020-01-13 13:31:01 +0100
commitd5178cdc05a0d91293d9ee2cef45ab9a1c515bac (patch)
treea292ff9e88907913ee4899e6939fd42c8b473d97 /src/reclaim
parentedd1533118eccaa14eaa157d6ca8d29b8d691404 (diff)
downloadgnunet-d5178cdc05a0d91293d9ee2cef45ab9a1c515bac.tar.gz
gnunet-d5178cdc05a0d91293d9ee2cef45ab9a1c515bac.zip
Direct Namestore Deletion Implemented
Diffstat (limited to 'src/reclaim')
-rw-r--r--src/reclaim/plugin_rest_reclaim.c183
1 files changed, 158 insertions, 25 deletions
diff --git a/src/reclaim/plugin_rest_reclaim.c b/src/reclaim/plugin_rest_reclaim.c
index b42394906..bb08e6385 100644
--- a/src/reclaim/plugin_rest_reclaim.c
+++ b/src/reclaim/plugin_rest_reclaim.c
@@ -298,6 +298,73 @@ struct AttributeStoreHandle
298}; 298};
299 299
300/** 300/**
301 * Handle for attribute deletion request
302 */
303struct AttributeDeleteHandle
304{
305 /**
306 * DLL
307 */
308 struct AttributeDeleteHandle *next;
309
310 /**
311 * DLL
312 */
313 struct AttributeDeleteHandle *prev;
314
315 /**
316 * Client connection
317 */
318 struct IdpClient *client;
319
320 /**
321 * Identity
322 */
323 struct GNUNET_CRYPTO_EcdsaPrivateKey identity;
324
325
326 /**
327 * QueueEntry
328 */
329 struct GNUNET_NAMESTORE_QueueEntry *ns_qe;
330
331 /**
332 * Iterator
333 */
334 struct GNUNET_NAMESTORE_ZoneIterator *ns_it;
335
336 /**
337 * The attribute to delete
338 */
339 struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim;
340
341 /**
342 * The attestation to store
343 */
344 struct GNUNET_RECLAIM_ATTESTATION_Claim *attest;
345
346 /**
347 * Tickets to update
348 */
349 struct TicketRecordsEntry *tickets_to_update_head;
350
351 /**
352 * Tickets to update
353 */
354 struct TicketRecordsEntry *tickets_to_update_tail;
355
356 /**
357 * Attribute label
358 */
359 char *label;
360
361 /**
362 * request id
363 */
364 uint32_t r_id;
365};
366
367/**
301 * Handle to the service. 368 * Handle to the service.
302 */ 369 */
303struct GNUNET_RECLAIM_Handle 370struct GNUNET_RECLAIM_Handle
@@ -502,6 +569,21 @@ finished_cont (void *cls, int32_t success, const char *emsg)
502 GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle); 569 GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle);
503} 570}
504 571
572static void
573delete_finished_cb (void *cls, int32_t success, const char *emsg)
574{
575 struct RequestHandle *handle = cls;
576 struct MHD_Response *resp;
577
578 resp = GNUNET_REST_create_response (emsg);
579 if (GNUNET_OK != success)
580 {
581 GNUNET_SCHEDULER_add_now (&do_error, handle);
582 return;
583 }
584 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
585 GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle);
586}
505 587
506/** 588/**
507 * Return attributes for identity 589 * Return attributes for identity
@@ -674,10 +756,6 @@ add_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle,
674 ash->exp.rel_value_us = exp_interval->rel_value_us; 756 ash->exp.rel_value_us = exp_interval->rel_value_us;
675 ash->attest = attribute; 757 ash->attest = attribute;
676 ash->client = idp; 758 ash->client = idp;
677 /*GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Type:%u\n", type);
678 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ID:%s\n", id_str);
679 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Size:%u\n", data_size);
680 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Data:%s\n", data);*/
681 buf_size = GNUNET_RECLAIM_ATTESTATION_serialize_get_size (ash->attest); 759 buf_size = GNUNET_RECLAIM_ATTESTATION_serialize_get_size (ash->attest);
682 buf = GNUNET_malloc (buf_size); 760 buf = GNUNET_malloc (buf_size);
683 // Give the ash a new id if unset 761 // Give the ash a new id if unset
@@ -716,15 +794,87 @@ list_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle,
716 return; 794 return;
717} 795}
718 796
719/*Placeholder*/ 797/*WIP*/
720static void 798static void
721delete_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle, 799delete_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle,
722 const char *url, 800 const char *url,
723 void *cls) 801 void *cls)
724{ 802{
725 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Deleting Attestations not supported\n"); 803 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key;
726 GNUNET_SCHEDULER_add_now (&do_error, cls); 804 struct RequestHandle *handle = cls;
727 return; 805 struct GNUNET_RECLAIM_ATTESTATION_Claim attr;
806 struct EgoEntry *ego_entry;
807 char *identity_id_str;
808 char *identity;
809 char *id;
810
811 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting attestation.\n");
812 if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) >= strlen (
813 handle->url))
814 {
815 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
816 GNUNET_SCHEDULER_add_now (&do_error, handle);
817 return;
818 }
819 identity_id_str =
820 strdup (handle->url + strlen (
821 GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) + 1);
822 identity = strtok (identity_id_str, "/");
823 id = strtok (NULL, "/");
824 if ((NULL == identity) || (NULL == id))
825 {
826 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Malformed request.\n");
827 GNUNET_free (identity_id_str);
828 GNUNET_SCHEDULER_add_now (&do_error, handle);
829 return;
830 }
831
832 for (ego_entry = handle->ego_head; NULL != ego_entry;
833 ego_entry = ego_entry->next)
834 if (0 == strcmp (identity, ego_entry->identifier))
835 break;
836 handle->resp_object = json_array ();
837 if (NULL == ego_entry)
838 {
839 // Done
840 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
841 GNUNET_free (identity_id_str);
842 GNUNET_SCHEDULER_add_now (&return_response, handle);
843 return;
844 }
845 priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
846 handle->idp = GNUNET_RECLAIM_connect (cfg);
847 memset (&attr, 0, sizeof(struct GNUNET_RECLAIM_ATTESTATION_Claim));
848 GNUNET_STRINGS_string_to_data (id, strlen (id), &attr.id, sizeof(uint64_t));
849 attr.name = "";
850
851 struct GNUNET_RECLAIM_Handle *h = handle->idp;
852 struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey = priv_key;
853
854 struct AttributeDeleteHandle *adh;
855 struct IdpClient *idp = handle;
856 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ATTRIBUTE_DELETE message\n");
857 struct GNUNET_NAMESTORE_Handle *nsh;
858 nsh = GNUNET_NAMESTORE_connect (cfg);
859 adh = GNUNET_new (struct AttributeDeleteHandle);
860 adh->attest = &attr;
861 adh->r_id = h->r_id_gen++;
862 adh->identity = *pkey;
863 adh->label = GNUNET_STRINGS_data_to_string_alloc (&adh->attest->id,
864 sizeof(uint64_t));
865 /*GNUNET_SERVICE_client_continue (idp->client);*/
866 adh->client = idp;
867 /*GNUNET_CONTAINER_DLL_insert (idp->delete_op_head, idp->delete_op_tail, adh);*/
868 adh->ns_qe = GNUNET_NAMESTORE_records_store (nsh,
869 &adh->identity,
870 adh->label,
871 0,
872 NULL,
873 &delete_finished_cb,
874 adh);
875
876
877 GNUNET_free (identity_id_str);
728} 878}
729 879
730/** 880/**
@@ -958,23 +1108,6 @@ list_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle,
958} 1108}
959 1109
960 1110
961static void
962delete_finished_cb (void *cls, int32_t success, const char *emsg)
963{
964 struct RequestHandle *handle = cls;
965 struct MHD_Response *resp;
966
967 resp = GNUNET_REST_create_response (emsg);
968 if (GNUNET_OK != success)
969 {
970 GNUNET_SCHEDULER_add_now (&do_error, handle);
971 return;
972 }
973 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
974 GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle);
975}
976
977
978/** 1111/**
979 * List attributes for identity request 1112 * List attributes for identity request
980 * 1113 *