allow access to raw /keys response

This commit is contained in:
Florian Dold 2016-05-24 02:28:03 +02:00
parent fc09e6a8fe
commit 8c3ffbf2a3
2 changed files with 44 additions and 4 deletions

View File

@ -108,6 +108,12 @@ struct TALER_EXCHANGE_Handle
*/ */
struct TALER_EXCHANGE_Keys key_data; 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. * Stage of the exchange's initialization routines.
*/ */
@ -623,11 +629,18 @@ keys_completed_cb (void *cls,
case 0: case 0:
break; break;
case MHD_HTTP_OK: case MHD_HTTP_OK:
if ( (NULL == resp_obj) || if (NULL == resp_obj)
(GNUNET_OK != {
decode_keys_json (resp_obj,
&kr->exchange->key_data)) )
response_code = 0; 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; break;
default: default:
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 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, GNUNET_array_grow (exchange->key_data.auditors,
exchange->key_data.num_auditors, exchange->key_data.num_auditors,
0); 0);
json_decref (exchange->key_data_raw);
GNUNET_free (exchange->url); GNUNET_free (exchange->url);
GNUNET_free (exchange); 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 */ /* end of exchange_api_handle.c */

View File

@ -276,6 +276,17 @@ const struct TALER_EXCHANGE_Keys *
TALER_EXCHANGE_get_keys (const struct TALER_EXCHANGE_Handle *exchange); 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 * Test if the given @a pub is a the current signing key from the exchange
* according to @a keys. * according to @a keys.