From 8c3ffbf2a356b7c684bb65b8678e819183e52d76 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Tue, 24 May 2016 02:28:03 +0200 Subject: allow access to raw /keys response --- src/exchange-lib/exchange_api_handle.c | 37 ++++++++++++++++++++++++++++++---- src/include/taler_exchange_service.h | 11 ++++++++++ 2 files changed, 44 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/exchange-lib/exchange_api_handle.c b/src/exchange-lib/exchange_api_handle.c index 356a2fd27..6de5ee59b 100644 --- a/src/exchange-lib/exchange_api_handle.c +++ b/src/exchange-lib/exchange_api_handle.c @@ -108,6 +108,12 @@ struct TALER_EXCHANGE_Handle */ struct TALER_EXCHANGE_Keys key_data; + /** + * Raw key data of the exchange, only valid if + * @e handshake_complete is past stage #MHS_CERT. + */ + json_t *key_data_raw; + /** * Stage of the exchange's initialization routines. */ @@ -623,11 +629,18 @@ keys_completed_cb (void *cls, case 0: break; case MHD_HTTP_OK: - if ( (NULL == resp_obj) || - (GNUNET_OK != - decode_keys_json (resp_obj, - &kr->exchange->key_data)) ) + if (NULL == resp_obj) + { response_code = 0; + break; + } + if (GNUNET_OK != + decode_keys_json (resp_obj, &kr->exchange->key_data)) + { + response_code = 0; + break; + } + exchange->key_data_raw = json_deep_copy (resp_obj); break; default: GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -806,6 +819,7 @@ TALER_EXCHANGE_disconnect (struct TALER_EXCHANGE_Handle *exchange) GNUNET_array_grow (exchange->key_data.auditors, exchange->key_data.num_auditors, 0); + json_decref (exchange->key_data_raw); GNUNET_free (exchange->url); GNUNET_free (exchange); } @@ -896,4 +910,19 @@ TALER_EXCHANGE_get_keys (const struct TALER_EXCHANGE_Handle *exchange) } +/** + * Obtain the keys from the exchange in the + * raw JSON format + * + * @param exchange the exchange handle + * @return the exchange's keys in raw JSON + */ +json_t * +TALER_EXCHANGE_get_keys_raw (const struct TALER_EXCHANGE_Handle *exchange) +{ + return json_deep_copy (exchange->key_data_raw); +} + + + /* end of exchange_api_handle.c */ diff --git a/src/include/taler_exchange_service.h b/src/include/taler_exchange_service.h index 57ab51253..1655e1a67 100644 --- a/src/include/taler_exchange_service.h +++ b/src/include/taler_exchange_service.h @@ -276,6 +276,17 @@ const struct TALER_EXCHANGE_Keys * TALER_EXCHANGE_get_keys (const struct TALER_EXCHANGE_Handle *exchange); +/** + * Obtain the keys from the exchange in the + * raw JSON format + * + * @param exchange the exchange handle + * @return the exchange's keys in raw JSON + */ +json_t * +TALER_EXCHANGE_get_keys_raw (const struct TALER_EXCHANGE_Handle *exchange); + + /** * Test if the given @a pub is a the current signing key from the exchange * according to @a keys. -- cgit v1.2.3