aboutsummaryrefslogtreecommitdiff
path: root/src/reclaim/plugin_rest_reclaim.c
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2020-02-04 21:15:59 +0100
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2020-02-09 20:38:10 +0100
commitad342b7e0870185522c7dcb846e71029fcfda335 (patch)
tree22dfa48bc4334d6b381bdb76458eb4c078ff9ac6 /src/reclaim/plugin_rest_reclaim.c
parent55f6d26b7424d660c99bc89f3677b20294e87a27 (diff)
downloadgnunet-ad342b7e0870185522c7dcb846e71029fcfda335.tar.gz
gnunet-ad342b7e0870185522c7dcb846e71029fcfda335.zip
add attestation API
Diffstat (limited to 'src/reclaim/plugin_rest_reclaim.c')
-rw-r--r--src/reclaim/plugin_rest_reclaim.c91
1 files changed, 29 insertions, 62 deletions
diff --git a/src/reclaim/plugin_rest_reclaim.c b/src/reclaim/plugin_rest_reclaim.c
index fcb34e11a..6f7a5987b 100644
--- a/src/reclaim/plugin_rest_reclaim.c
+++ b/src/reclaim/plugin_rest_reclaim.c
@@ -712,13 +712,14 @@ list_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle,
712 priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); 712 priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
713 handle->idp = GNUNET_RECLAIM_connect (cfg); 713 handle->idp = GNUNET_RECLAIM_connect (cfg);
714 handle->attest_it = GNUNET_RECLAIM_get_attestations_start (handle->idp, 714 handle->attest_it = GNUNET_RECLAIM_get_attestations_start (handle->idp,
715 priv_key, 715 priv_key,
716 &collect_error_cb, 716 &collect_error_cb,
717 handle, 717 handle,
718 &attest_collect, 718 &attest_collect,
719 handle, 719 handle,
720 &collect_finished_cb, 720 &
721 handle); 721 collect_finished_cb,
722 handle);
722} 723}
723 724
724 725
@@ -1000,67 +1001,33 @@ parse_jwt (const struct GNUNET_RECLAIM_Attestation *attest,
1000static void 1001static void
1001attr_collect (void *cls, 1002attr_collect (void *cls,
1002 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, 1003 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
1003 const struct GNUNET_RECLAIM_Attribute *attr, 1004 const struct GNUNET_RECLAIM_Attribute *attr)
1004 const struct GNUNET_RECLAIM_Attestation *attest)
1005{ 1005{
1006 struct RequestHandle *handle = cls; 1006 struct RequestHandle *handle = cls;
1007 json_t *attr_obj; 1007 json_t *attr_obj;
1008 const char *type; 1008 const char *type;
1009 char *id_str; 1009 char *id_str;
1010 1010
1011 if (GNUNET_NO == GNUNET_RECLAIM_id_is_zero (&attr->attestation)) 1011 char *tmp_value;
1012 { 1012 tmp_value = GNUNET_RECLAIM_attribute_value_to_string (attr->type,
1013 struct GNUNET_RECLAIM_Attribute *attr2; 1013 attr->data,
1014 attr2 = parse_jwt (attest, attr->data); 1014 attr->data_size);
1015 if (NULL == attr2) 1015 attr_obj = json_object ();
1016 { 1016 json_object_set_new (attr_obj, "value", json_string (tmp_value));
1017 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1017 json_object_set_new (attr_obj, "name", json_string (attr->name));
1018 "Attribute Collection with unparsed Attestation\n"); 1018
1019 return; 1019 json_object_set_new (attr_obj, "flag", json_string ("1"));
1020 } 1020 type = GNUNET_RECLAIM_attribute_number_to_typename (attr->type);
1021 attr2->name = attr->name; 1021 json_object_set_new (attr_obj, "type", json_string (type));
1022 char *tmp_value; 1022 id_str = GNUNET_STRINGS_data_to_string_alloc (&attr->id,
1023 tmp_value = GNUNET_RECLAIM_attribute_value_to_string (attr2->type, 1023 sizeof(attr->id));
1024 attr2->data, 1024 json_object_set_new (attr_obj, "id", json_string (id_str));
1025 attr2->data_size); 1025 id_str = GNUNET_STRINGS_data_to_string_alloc (&attr->attestation,
1026 attr_obj = json_object (); 1026 sizeof(attr->attestation));
1027 json_object_set_new (attr_obj, "value", json_string (tmp_value)); 1027 json_object_set_new (attr_obj, "attestation", json_string (id_str));
1028 json_object_set_new (attr_obj, "name", json_string (attr2->name)); 1028 json_array_append (handle->resp_object, attr_obj);
1029 json_object_set_new (attr_obj, "flag", json_string ("1")); 1029 json_decref (attr_obj);
1030 type = GNUNET_RECLAIM_attribute_number_to_typename (attr2->type); 1030 GNUNET_free (tmp_value);
1031 json_object_set_new (attr_obj, "type", json_string (type));
1032 id_str = GNUNET_STRINGS_data_to_string_alloc (&attr2->id,
1033 sizeof(attr2->id));
1034 json_object_set_new (attr_obj, "id", json_string (id_str));
1035 json_array_append (handle->resp_object, attr_obj);
1036 json_decref (attr_obj);
1037 GNUNET_free (tmp_value);
1038 }
1039 else
1040 {
1041 char *tmp_value;
1042 char *flag_str;
1043 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute: %s\n", attr->name);
1044
1045 tmp_value = GNUNET_RECLAIM_attribute_value_to_string (attr->type,
1046 attr->data,
1047 attr->data_size);
1048
1049 attr_obj = json_object ();
1050 json_object_set_new (attr_obj, "value", json_string (tmp_value));
1051 json_object_set_new (attr_obj, "name", json_string (attr->name));
1052 GNUNET_asprintf (&flag_str,"%d",attr->flag);
1053 json_object_set_new (attr_obj, "flag", json_string (flag_str));
1054 type = GNUNET_RECLAIM_attribute_number_to_typename (attr->type);
1055 json_object_set_new (attr_obj, "type", json_string (type));
1056 id_str = GNUNET_STRINGS_data_to_string_alloc (&attr->id,
1057 sizeof(attr->id));
1058 json_object_set_new (attr_obj, "id", json_string (id_str));
1059 json_array_append (handle->resp_object, attr_obj);
1060 json_decref (attr_obj);
1061 GNUNET_free (tmp_value);
1062 GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
1063 }
1064} 1031}
1065 1032
1066 1033