summaryrefslogtreecommitdiff
path: root/src/lib/exchange_api_handle.c
diff options
context:
space:
mode:
authorÖzgür Kesim <oec-taler@kesim.org>2022-01-23 01:31:02 +0100
committerÖzgür Kesim <oec-taler@kesim.org>2022-01-23 01:36:21 +0100
commit8684a9bfea9223808e33edca9f91b8bd76379fd0 (patch)
tree2354ad02b8ea515fe2de64cb8a42ca078f9f8b64 /src/lib/exchange_api_handle.c
parent1962ed6b0b44c6c7d3503b3340da1be147e25f87 (diff)
downloadexchange-8684a9bfea9223808e33edca9f91b8bd76379fd0.tar.gz
exchange-8684a9bfea9223808e33edca9f91b8bd76379fd0.tar.bz2
exchange-8684a9bfea9223808e33edca9f91b8bd76379fd0.zip
[age_restriction] progress 13/n
- major refactoring of extensions - extensions live now in a separate library, libtalerextensions - refactored all components using age_restriction accordingly - plumbing for plugin support for extensions roughly layed down
Diffstat (limited to 'src/lib/exchange_api_handle.c')
-rw-r--r--src/lib/exchange_api_handle.c71
1 files changed, 30 insertions, 41 deletions
diff --git a/src/lib/exchange_api_handle.c b/src/lib/exchange_api_handle.c
index aea09a81f..cf3d69d6a 100644
--- a/src/lib/exchange_api_handle.c
+++ b/src/lib/exchange_api_handle.c
@@ -795,50 +795,39 @@ decode_keys_json (const json_t *resp_obj,
}
/* Parse the supported extension(s): age-restriction. */
- /* TODO: maybe lift this into a FP in TALER_Extension ? */
+ /* TODO: maybe lift all this into a FP in TALER_Extension ? */
{
- json_t *age_restriction = json_object_get (resp_obj,
- "age_restriction");
-
- if (NULL != age_restriction)
- {
- bool critical;
- const char *version;
- const char *age_groups;
- struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_bool ("critical",
- &critical),
- GNUNET_JSON_spec_string ("version",
- &version),
- GNUNET_JSON_spec_string ("age_groups",
- &age_groups),
- GNUNET_JSON_spec_end ()
- };
-
- if (GNUNET_OK !=
- GNUNET_JSON_parse (age_restriction,
- spec,
- NULL, NULL))
- {
- GNUNET_break_op (0);
- return GNUNET_SYSERR;
- }
+ struct TALER_MasterSignatureP extensions_sig = {0};
+ json_t *extensions = NULL;
+ struct GNUNET_JSON_Specification ext_spec[] = {
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_json ("extensions",
+ &extensions)),
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_fixed_auto (
+ "extensions_sig",
+ &extensions_sig)),
+ GNUNET_JSON_spec_end ()
+ };
- if (critical || // do we care?
- 0 != strncmp (version, "1", 1) ) /* TODO: better compatibility check */
- {
- GNUNET_break_op (0);
- return GNUNET_SYSERR;
- }
+ /* 1. Search for extensions in the response to /keys */
+ EXITIF (GNUNET_OK !=
+ GNUNET_JSON_parse (resp_obj,
+ ext_spec,
+ NULL, NULL));
- if (GNUNET_OK !=
- TALER_parse_age_group_string (age_groups,
- &key_data->age_mask))
- {
- // TODO: print more specific error?
- GNUNET_break_op (0);
- return GNUNET_SYSERR;
- }
+ if (NULL != extensions)
+ {
+ /* 2. We have an extensions object. Verify its signature. */
+ EXITIF (GNUNET_OK !=
+ TALER_extensions_verify_json_config_signature (
+ extensions,
+ &extensions_sig,
+ &key_data->master_pub));
+
+ /* 3. Parse and set the the configuration of the extensions accordingly */
+ EXITIF (GNUNET_OK !=
+ TALER_extensions_load_json_config (extensions));
}
}