aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Voggenreiter <Markus.Voggenreiter@tum.de>2019-11-01 10:59:01 +0100
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2020-01-13 13:31:04 +0100
commit6fad96b4971e3067168932088dcaf6c3cbdcb124 (patch)
treece303eb691d51a6cdb6e7b46c04411eeb92e02b0
parent17af2a636fc8fd0c111c7550484b2582cb7eb64a (diff)
downloadgnunet-6fad96b4971e3067168932088dcaf6c3cbdcb124.tar.gz
gnunet-6fad96b4971e3067168932088dcaf6c3cbdcb124.zip
Listing of References with Attributes
-rw-r--r--src/reclaim-attribute/reclaim_attribute.c2
-rw-r--r--src/reclaim/plugin_rest_reclaim.c79
2 files changed, 55 insertions, 26 deletions
diff --git a/src/reclaim-attribute/reclaim_attribute.c b/src/reclaim-attribute/reclaim_attribute.c
index d958ba7f9..113ec7ef5 100644
--- a/src/reclaim-attribute/reclaim_attribute.c
+++ b/src/reclaim-attribute/reclaim_attribute.c
@@ -426,7 +426,7 @@ GNUNET_RECLAIM_ATTESTATION_reference_new (const char *attr_name,
426 GNUNET_memcpy (write_ptr, attr_name_tmp, strlen (attr_name_tmp) + 1); 426 GNUNET_memcpy (write_ptr, attr_name_tmp, strlen (attr_name_tmp) + 1);
427 attr->name = write_ptr; 427 attr->name = write_ptr;
428 428
429 write_ptr = (char *) &attr[1]; 429 write_ptr += strlen (attr_name) +1;
430 GNUNET_memcpy (write_ptr, ref_value_tmp, strlen (ref_value_tmp) + 1); 430 GNUNET_memcpy (write_ptr, ref_value_tmp, strlen (ref_value_tmp) + 1);
431 attr->reference_value = write_ptr; 431 attr->reference_value = write_ptr;
432 432
diff --git a/src/reclaim/plugin_rest_reclaim.c b/src/reclaim/plugin_rest_reclaim.c
index 7dd658886..f7713c284 100644
--- a/src/reclaim/plugin_rest_reclaim.c
+++ b/src/reclaim/plugin_rest_reclaim.c
@@ -638,7 +638,7 @@ static void
638attest_collect (void *cls, 638attest_collect (void *cls,
639 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, 639 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
640 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, 640 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
641 const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest, 641 const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest,
642 const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference) 642 const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference)
643{ 643{
644 struct RequestHandle *handle = cls; 644 struct RequestHandle *handle = cls;
@@ -1045,7 +1045,6 @@ add_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle,
1045 GNUNET_JSON_parse_free (attrspec); 1045 GNUNET_JSON_parse_free (attrspec);
1046} 1046}
1047 1047
1048
1049/** 1048/**
1050 * Collect all attributes for an ego 1049 * Collect all attributes for an ego
1051 * 1050 *
@@ -1054,47 +1053,77 @@ static void
1054attr_collect (void *cls, 1053attr_collect (void *cls,
1055 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, 1054 const struct GNUNET_CRYPTO_EcdsaPublicKey *identity,
1056 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, 1055 const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr,
1057 const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest, 1056 const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest,
1058 const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference) 1057 const struct GNUNET_RECLAIM_ATTESTATION_REFERENCE *reference)
1059{ 1058{
1060 struct RequestHandle *handle = cls; 1059 struct RequestHandle *handle = cls;
1061 json_t *attr_obj; 1060 json_t *attr_obj;
1062 const char *type; 1061 const char *type;
1063 char *tmp_value;
1064 char *id_str; 1062 char *id_str;
1065 1063
1066 if (NULL == attr) 1064 if ((NULL == attr)&& (NULL == reference))
1067 { 1065 {
1068 GNUNET_RECLAIM_get_attributes_next (handle->attr_it); 1066 GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
1069 return; 1067 return;
1070 } 1068 }
1071 1069
1072 if ((NULL == attr->name) || (NULL == attr->data)) 1070 if (NULL == attr)
1073 { 1071 {
1074 GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
1075 return;
1076 }
1077 1072
1078 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute: %s\n", attr->name); 1073 if ((NULL == reference->name) || (NULL == reference->reference_value))
1074 {
1075 GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
1076 return;
1077 }
1079 1078
1080 tmp_value = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type, 1079 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding reference as attribute: %s\n",
1081 attr->data, 1080 reference->name);
1082 attr->data_size); 1081
1082
1083 attr_obj = json_object ();
1084 json_object_set_new (attr_obj, "name", json_string (reference->name));
1085 json_object_set_new (attr_obj, "value", json_string (
1086 reference->reference_value));
1087 id_str = GNUNET_STRINGS_data_to_string_alloc (&reference->id, sizeof(uint64_t));
1088 json_object_set_new (attr_obj, "id", json_string (id_str));
1089 char *flag;
1090 flag = "1";
1091 json_object_set_new (attr_obj, "flag", json_string (flag));
1092 type = "String";
1093 json_object_set_new (attr_obj, "type", json_string (type));
1094 json_array_append (handle->resp_object, attr_obj);
1095 json_decref (attr_obj);
1096 GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
1083 1097
1084 attr_obj = json_object (); 1098 }
1085 json_object_set_new (attr_obj, "value", json_string (tmp_value)); 1099 else
1086 json_object_set_new (attr_obj, "name", json_string (attr->name)); 1100 {
1087 type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr->type); 1101 if ((NULL == attr->name) || (NULL == attr->data))
1088 json_object_set_new (attr_obj, "type", json_string (type)); 1102 {
1089 id_str = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(uint64_t)); 1103 GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
1090 json_object_set_new (attr_obj, "id", json_string (id_str)); 1104 return;
1091 json_array_append (handle->resp_object, attr_obj); 1105 }
1092 json_decref (attr_obj); 1106 char *tmp_value;
1093 GNUNET_free (tmp_value); 1107 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute: %s\n", attr->name);
1094 GNUNET_RECLAIM_get_attributes_next (handle->attr_it); 1108
1109 tmp_value = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type,
1110 attr->data,
1111 attr->data_size);
1112
1113 attr_obj = json_object ();
1114 json_object_set_new (attr_obj, "value", json_string (tmp_value));
1115 json_object_set_new (attr_obj, "name", json_string (attr->name));
1116 type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr->type);
1117 json_object_set_new (attr_obj, "type", json_string (type));
1118 id_str = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(uint64_t));
1119 json_object_set_new (attr_obj, "id", json_string (id_str));
1120 json_array_append (handle->resp_object, attr_obj);
1121 json_decref (attr_obj);
1122 GNUNET_free (tmp_value);
1123 GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
1124 }
1095} 1125}
1096 1126
1097
1098/** 1127/**
1099 * List attributes for identity request 1128 * List attributes for identity request
1100 * 1129 *