parse the "age_restricted_denoms" in "/keys"
This commit is contained in:
parent
d91750ca0f
commit
a6260049a0
@ -159,6 +159,11 @@ struct TALER_EXCHANGE_DenomPublicKey
|
|||||||
* revoked by the exchange.
|
* revoked by the exchange.
|
||||||
*/
|
*/
|
||||||
bool revoked;
|
bool revoked;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is the denomination age-restricted?
|
||||||
|
*/
|
||||||
|
bool age_restricted;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -345,6 +345,7 @@ parse_json_denomkey (struct TALER_EXCHANGE_DenomPublicKey *denom_key,
|
|||||||
GNUNET_JSON_spec_end ()
|
GNUNET_JSON_spec_end ()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
GNUNET_JSON_parse (denom_key_obj,
|
GNUNET_JSON_parse (denom_key_obj,
|
||||||
spec,
|
spec,
|
||||||
@ -793,14 +794,34 @@ decode_keys_json (const json_t *resp_obj,
|
|||||||
|
|
||||||
/* parse the denomination keys, merging with the
|
/* parse the denomination keys, merging with the
|
||||||
possibly EXISTING array as required (/keys cherry picking) */
|
possibly EXISTING array as required (/keys cherry picking) */
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
char *name;
|
||||||
|
bool is_optional_age_restriction;
|
||||||
|
} section[2] = {
|
||||||
|
/* The denominations can be in "denoms" or in
|
||||||
|
* "age_restricted_denoms", the later being optional */
|
||||||
|
{ "denoms", false },
|
||||||
|
{ "age_restricted_denoms", true},
|
||||||
|
};
|
||||||
|
|
||||||
|
for (size_t s = 0; s < sizeof(section) / sizeof(section[0]); s++)
|
||||||
{
|
{
|
||||||
json_t *denom_keys_array;
|
json_t *denom_keys_array;
|
||||||
json_t *denom_key_obj;
|
json_t *denom_key_obj;
|
||||||
unsigned int index;
|
unsigned int index;
|
||||||
|
|
||||||
EXITIF (NULL == (denom_keys_array =
|
denom_keys_array = json_object_get (resp_obj,
|
||||||
json_object_get (resp_obj,
|
section[s].name);
|
||||||
"denoms")));
|
|
||||||
|
EXITIF (NULL == denom_keys_array &&
|
||||||
|
! section[s].is_optional_age_restriction);
|
||||||
|
|
||||||
|
if (NULL == denom_keys_array &&
|
||||||
|
section[s].is_optional_age_restriction)
|
||||||
|
continue;
|
||||||
|
|
||||||
EXITIF (JSON_ARRAY != json_typeof (denom_keys_array));
|
EXITIF (JSON_ARRAY != json_typeof (denom_keys_array));
|
||||||
|
|
||||||
json_array_foreach (denom_keys_array, index, denom_key_obj) {
|
json_array_foreach (denom_keys_array, index, denom_key_obj) {
|
||||||
@ -817,6 +838,11 @@ decode_keys_json (const json_t *resp_obj,
|
|||||||
&key_data->master_pub,
|
&key_data->master_pub,
|
||||||
hash_context));
|
hash_context));
|
||||||
|
|
||||||
|
/* Mark age restriction according where we got this denomination from,
|
||||||
|
* "denoms" or "age_restricted_denoms" */
|
||||||
|
if (section[s].is_optional_age_restriction)
|
||||||
|
dk.age_restricted = true;
|
||||||
|
|
||||||
for (unsigned int j = 0;
|
for (unsigned int j = 0;
|
||||||
j<key_data->num_denom_keys;
|
j<key_data->num_denom_keys;
|
||||||
j++)
|
j++)
|
||||||
@ -849,6 +875,7 @@ decode_keys_json (const json_t *resp_obj,
|
|||||||
dk.valid_from);
|
dk.valid_from);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* parse the auditor information */
|
/* parse the auditor information */
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user