summaryrefslogtreecommitdiff
path: root/src/reclaim/oidc_helper.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/reclaim/oidc_helper.c')
-rw-r--r--src/reclaim/oidc_helper.c57
1 files changed, 46 insertions, 11 deletions
diff --git a/src/reclaim/oidc_helper.c b/src/reclaim/oidc_helper.c
index 84a90833c..bd3a8ee05 100644
--- a/src/reclaim/oidc_helper.c
+++ b/src/reclaim/oidc_helper.c
@@ -223,6 +223,8 @@ generate_userinfo_json (const struct GNUNET_IDENTITY_PublicKey *sub_key,
i++;
}
+ int addr_is_aggregated = GNUNET_NO;
+ int addr_is_normal = GNUNET_NO;
for (le = attrs->list_head; NULL != le; le = le->next)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -230,7 +232,6 @@ generate_userinfo_json (const struct GNUNET_IDENTITY_PublicKey *sub_key,
le->attribute->name);
if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&le->attribute->credential))
{
-
attr_val_str =
GNUNET_RECLAIM_attribute_value_to_string (le->attribute->type,
le->attribute->data,
@@ -238,13 +239,22 @@ generate_userinfo_json (const struct GNUNET_IDENTITY_PublicKey *sub_key,
/**
* There is this wierd quirk that the individual address claim(s) must be
* inside a JSON object of the "address" claim.
- * FIXME: Possibly include formatted claim here
*/
if (GNUNET_YES == is_claim_in_address_scope (le->attribute->name))
{
+ if (GNUNET_YES == addr_is_aggregated)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Address is set as aggregated claim. Skipping self-issued value...\n");
+ GNUNET_free (attr_val_str);
+ continue;
+ }
+ addr_is_normal = GNUNET_YES;
+
if (NULL == addr_claim)
{
addr_claim = json_object ();
+ json_object_set_new (body, "address", addr_claim);
}
json_object_set_new (addr_claim, le->attribute->name,
json_string (attr_val_str));
@@ -276,17 +286,42 @@ generate_userinfo_json (const struct GNUNET_IDENTITY_PublicKey *sub_key,
le->attribute->name);
continue;
}
- // Presentation exists, hence take the respective source str
- GNUNET_asprintf (&source_name,
- "src%d",
- j);
- json_object_set_new (aggr_names, le->attribute->name,
- json_string (source_name));
- GNUNET_free (source_name);
+ /**
+ * There is this wierd quirk that the individual address claim(s) must be
+ * inside a JSON object of the "address" claim.
+ */
+ if (GNUNET_YES == is_claim_in_address_scope (le->attribute->name))
+ {
+ if (GNUNET_YES == addr_is_normal)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Address is already set as normal claim. Skipping attested value...\n");
+ continue;
+ }
+ addr_is_aggregated = GNUNET_YES;
+ /** This is/can only be set once! **/
+ if (NULL != addr_claim)
+ continue;
+ addr_claim = json_object ();
+ GNUNET_asprintf (&source_name,
+ "src%d",
+ j);
+ json_object_set_new (aggr_names, "address",
+ json_string (source_name));
+ GNUNET_free (source_name);
+ }
+ else
+ {
+ // Presentation exists, hence take the respective source str
+ GNUNET_asprintf (&source_name,
+ "src%d",
+ j);
+ json_object_set_new (aggr_names, le->attribute->name,
+ json_string (source_name));
+ GNUNET_free (source_name);
+ }
}
}
- if (NULL != addr_claim)
- json_object_set_new (body, "address", addr_claim);
if (0 != i)
{
json_object_set_new (body, "_claim_names", aggr_names);