diff options
author | Markus Voggenreiter <Markus.Voggenreiter@tum.de> | 2019-10-27 22:43:23 +0100 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2020-01-13 13:31:03 +0100 |
commit | b62682f35d3752eff4b9d7ff52d47e0bfbd6b6f5 (patch) | |
tree | bfa262535f1ed7ce2e343972795a20fd070533db /src/reclaim/plugin_rest_reclaim.c | |
parent | df903a80b2681567bf0b1afe9f1e3c89b13efbc2 (diff) | |
download | gnunet-b62682f35d3752eff4b9d7ff52d47e0bfbd6b6f5.tar.gz gnunet-b62682f35d3752eff4b9d7ff52d47e0bfbd6b6f5.zip |
Deletion of Reference Type
Diffstat (limited to 'src/reclaim/plugin_rest_reclaim.c')
-rw-r--r-- | src/reclaim/plugin_rest_reclaim.c | 114 |
1 files changed, 112 insertions, 2 deletions
diff --git a/src/reclaim/plugin_rest_reclaim.c b/src/reclaim/plugin_rest_reclaim.c index b52cf9650..5066eef58 100644 --- a/src/reclaim/plugin_rest_reclaim.c +++ b/src/reclaim/plugin_rest_reclaim.c | |||
@@ -483,7 +483,8 @@ add_attestation_ref_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
483 | return; | 483 | return; |
484 | } | 484 | } |
485 | identity = handle->url + strlen ( | 485 | identity = handle->url + strlen ( |
486 | GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) + strlen ("reference/") + 1; | 486 | GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) + strlen ("reference/") |
487 | + 1; | ||
487 | for (ego_entry = handle->ego_head; NULL != ego_entry; | 488 | for (ego_entry = handle->ego_head; NULL != ego_entry; |
488 | ego_entry = ego_entry->next) | 489 | ego_entry = ego_entry->next) |
489 | if (0 == strcmp (identity, ego_entry->identifier)) | 490 | if (0 == strcmp (identity, ego_entry->identifier)) |
@@ -734,6 +735,102 @@ list_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
734 | } | 735 | } |
735 | 736 | ||
736 | /** | 737 | /** |
738 | * Deletes reference from an identity | ||
739 | * | ||
740 | * @param con_handle the connection handle | ||
741 | * @param url the url | ||
742 | * @param cls the RequestHandle | ||
743 | */ | ||
744 | static void | ||
745 | delete_attestation_ref_cont (struct GNUNET_REST_RequestHandle *con_handle, | ||
746 | const char *url, | ||
747 | void *cls) | ||
748 | { | ||
749 | struct RequestHandle *handle = cls; | ||
750 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key; | ||
751 | struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *attr; | ||
752 | struct EgoEntry *ego_entry; | ||
753 | char *identity; | ||
754 | char *identity_id_str; | ||
755 | char *id; | ||
756 | char term_data[handle->rest_handle->data_size + 1]; | ||
757 | json_t *data_json; | ||
758 | json_error_t err; | ||
759 | |||
760 | struct GNUNET_JSON_Specification attrspec[] = | ||
761 | { GNUNET_RECLAIM_JSON_spec_claim_attest_ref (&attr), | ||
762 | GNUNET_JSON_spec_end () }; | ||
763 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
764 | "Deleting attestation reference.\n"); | ||
765 | if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) + strlen ( | ||
766 | "reference/") + 1 >= strlen ( | ||
767 | handle->url)) | ||
768 | { | ||
769 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n"); | ||
770 | GNUNET_SCHEDULER_add_now (&do_error, handle); | ||
771 | return; | ||
772 | } | ||
773 | identity_id_str = strdup (handle->url + strlen ( | ||
774 | GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) | ||
775 | + strlen ("reference/") | ||
776 | + 1); | ||
777 | identity = strtok (identity_id_str, "/"); | ||
778 | id = strtok (NULL, "/"); | ||
779 | |||
780 | if ((NULL == identity) || (NULL == id)) | ||
781 | { | ||
782 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Malformed request.\n"); | ||
783 | GNUNET_SCHEDULER_add_now (&do_error, handle); | ||
784 | return; | ||
785 | } | ||
786 | for (ego_entry = handle->ego_head; NULL != ego_entry; | ||
787 | ego_entry = ego_entry->next) | ||
788 | if (0 == strcmp (identity, ego_entry->identifier)) | ||
789 | break; | ||
790 | handle->resp_object = json_array (); | ||
791 | if (NULL == ego_entry) | ||
792 | { | ||
793 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity); | ||
794 | GNUNET_SCHEDULER_add_now (&return_response, handle); | ||
795 | return; | ||
796 | } | ||
797 | priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); | ||
798 | if (0 >= handle->rest_handle->data_size) | ||
799 | { | ||
800 | GNUNET_SCHEDULER_add_now (&do_error, handle); | ||
801 | return; | ||
802 | } | ||
803 | |||
804 | term_data[handle->rest_handle->data_size] = '\0'; | ||
805 | GNUNET_memcpy (term_data, | ||
806 | handle->rest_handle->data, | ||
807 | handle->rest_handle->data_size); | ||
808 | data_json = json_loads (term_data, JSON_DECODE_ANY, &err); | ||
809 | GNUNET_assert (GNUNET_OK == | ||
810 | GNUNET_JSON_parse (data_json, attrspec, NULL, NULL)); | ||
811 | json_decref (data_json); | ||
812 | if (NULL == attr) | ||
813 | { | ||
814 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
815 | "Unable to parse attestation reference from %s\n", | ||
816 | term_data); | ||
817 | GNUNET_SCHEDULER_add_now (&do_error, handle); | ||
818 | return; | ||
819 | } | ||
820 | GNUNET_STRINGS_string_to_data (id, strlen (id), &attr->id, sizeof(uint64_t)); | ||
821 | |||
822 | handle->idp = GNUNET_RECLAIM_connect (cfg); | ||
823 | handle->idp_op = GNUNET_RECLAIM_attestation_reference_delete (handle->idp, | ||
824 | priv_key, | ||
825 | attr, | ||
826 | & | ||
827 | delete_finished_cb, | ||
828 | handle); | ||
829 | GNUNET_JSON_parse_free (attrspec); | ||
830 | } | ||
831 | |||
832 | |||
833 | /** | ||
737 | * Deletes attestation from an identity | 834 | * Deletes attestation from an identity |
738 | * | 835 | * |
739 | * @param con_handle the connection handle | 836 | * @param con_handle the connection handle |
@@ -745,8 +842,21 @@ delete_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
745 | const char *url, | 842 | const char *url, |
746 | void *cls) | 843 | void *cls) |
747 | { | 844 | { |
748 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key; | ||
749 | struct RequestHandle *handle = cls; | 845 | struct RequestHandle *handle = cls; |
846 | /* Check for substring "reference" */ | ||
847 | if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) < strlen ( | ||
848 | handle->url)) | ||
849 | { | ||
850 | if ( strncmp ("reference", (handle->url + strlen ( | ||
851 | GNUNET_REST_API_NS_RECLAIM_ATTESTATION_REFERENCE) | ||
852 | + 1), strlen ( | ||
853 | "reference")) == 0) | ||
854 | { | ||
855 | delete_attestation_ref_cont (con_handle,url,cls); | ||
856 | return; | ||
857 | } | ||
858 | } | ||
859 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key; | ||
750 | struct GNUNET_RECLAIM_ATTESTATION_Claim attr; | 860 | struct GNUNET_RECLAIM_ATTESTATION_Claim attr; |
751 | struct EgoEntry *ego_entry; | 861 | struct EgoEntry *ego_entry; |
752 | char *identity_id_str; | 862 | char *identity_id_str; |