diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2016-12-14 17:35:49 +0100 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2016-12-14 17:35:49 +0100 |
commit | 745f0dc8f07ef5275f829b13524d6afcc251e58a (patch) | |
tree | 32c8109d341b614fc6841831a111026713db0481 /src/credential/plugin_rest_credential.c | |
parent | 02066879bd7eb841d01e1359021de3bc3aca11e0 (diff) | |
download | gnunet-745f0dc8f07ef5275f829b13524d6afcc251e58a.tar.gz gnunet-745f0dc8f07ef5275f829b13524d6afcc251e58a.zip |
-fixes, prettify
Diffstat (limited to 'src/credential/plugin_rest_credential.c')
-rw-r--r-- | src/credential/plugin_rest_credential.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/credential/plugin_rest_credential.c b/src/credential/plugin_rest_credential.c index cdd0e86e9..f6e4fc5a8 100644 --- a/src/credential/plugin_rest_credential.c +++ b/src/credential/plugin_rest_credential.c | |||
@@ -41,7 +41,7 @@ | |||
41 | 41 | ||
42 | #define GNUNET_REST_JSONAPI_CREDENTIAL_TYPEINFO "credential" | 42 | #define GNUNET_REST_JSONAPI_CREDENTIAL_TYPEINFO "credential" |
43 | 43 | ||
44 | #define GNUNET_REST_JSONAPI_CREDENTIAL_CHAIN "chain" | 44 | #define GNUNET_REST_JSONAPI_DELEGATIONS "delegations" |
45 | 45 | ||
46 | #define GNUNET_REST_JSONAPI_CREDENTIAL_ISSUER_ATTR "attribute" | 46 | #define GNUNET_REST_JSONAPI_CREDENTIAL_ISSUER_ATTR "attribute" |
47 | 47 | ||
@@ -273,6 +273,7 @@ static void | |||
273 | handle_verify_response (void *cls, | 273 | handle_verify_response (void *cls, |
274 | unsigned int d_count, | 274 | unsigned int d_count, |
275 | struct GNUNET_CREDENTIAL_Delegation *delegation_chain, | 275 | struct GNUNET_CREDENTIAL_Delegation *delegation_chain, |
276 | unsigned int c_count, | ||
276 | struct GNUNET_CREDENTIAL_Credential *cred) | 277 | struct GNUNET_CREDENTIAL_Credential *cred) |
277 | { | 278 | { |
278 | 279 | ||
@@ -282,7 +283,8 @@ handle_verify_response (void *cls, | |||
282 | struct GNUNET_JSONAPI_Resource *json_resource; | 283 | struct GNUNET_JSONAPI_Resource *json_resource; |
283 | json_t *cred_obj; | 284 | json_t *cred_obj; |
284 | json_t *attr_obj; | 285 | json_t *attr_obj; |
285 | json_t *result_array; | 286 | json_t *cred_array; |
287 | json_t *attr_array; | ||
286 | char *result; | 288 | char *result; |
287 | uint32_t i; | 289 | uint32_t i; |
288 | 290 | ||
@@ -298,25 +300,33 @@ handle_verify_response (void *cls, | |||
298 | json_resource = GNUNET_JSONAPI_resource_new (GNUNET_REST_JSONAPI_CREDENTIAL_TYPEINFO, | 300 | json_resource = GNUNET_JSONAPI_resource_new (GNUNET_REST_JSONAPI_CREDENTIAL_TYPEINFO, |
299 | handle->issuer_attr); | 301 | handle->issuer_attr); |
300 | cred_obj = credential_to_json (cred); | 302 | cred_obj = credential_to_json (cred); |
301 | result_array = json_array (); | 303 | attr_array = json_array (); |
302 | for (i = 0; i < d_count; i++) | 304 | for (i = 0; i < d_count; i++) |
303 | { | 305 | { |
304 | attr_obj = attribute_delegation_to_json (&delegation_chain[i]); | 306 | attr_obj = attribute_delegation_to_json (&delegation_chain[i]); |
305 | json_array_append (result_array, attr_obj); | 307 | json_array_append (attr_array, attr_obj); |
306 | json_decref (attr_obj); | 308 | json_decref (attr_obj); |
307 | } | 309 | } |
310 | cred_array = json_array (); | ||
311 | for (i=0;i<c_count;i++) | ||
312 | { | ||
313 | cred_obj = credential_to_json (&cred[i]); | ||
314 | json_array_append (cred_array, cred_obj); | ||
315 | json_decref (cred_obj); | ||
316 | } | ||
308 | GNUNET_JSONAPI_resource_add_attr (json_resource, | 317 | GNUNET_JSONAPI_resource_add_attr (json_resource, |
309 | GNUNET_REST_JSONAPI_CREDENTIAL, | 318 | GNUNET_REST_JSONAPI_CREDENTIAL, |
310 | cred_obj); | 319 | cred_array); |
311 | GNUNET_JSONAPI_resource_add_attr (json_resource, | 320 | GNUNET_JSONAPI_resource_add_attr (json_resource, |
312 | GNUNET_REST_JSONAPI_CREDENTIAL_CHAIN, | 321 | GNUNET_REST_JSONAPI_DELEGATIONS, |
313 | result_array); | 322 | attr_array); |
314 | GNUNET_JSONAPI_document_resource_add (json_document, json_resource); | 323 | GNUNET_JSONAPI_document_resource_add (json_document, json_resource); |
315 | GNUNET_JSONAPI_document_serialize (json_document, &result); | 324 | GNUNET_JSONAPI_document_serialize (json_document, &result); |
316 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 325 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
317 | "Result %s\n", | 326 | "Result %s\n", |
318 | result); | 327 | result); |
319 | json_decref (result_array); | 328 | json_decref (attr_array); |
329 | json_decref (cred_array); | ||
320 | GNUNET_JSONAPI_document_delete (json_document); | 330 | GNUNET_JSONAPI_document_delete (json_document); |
321 | resp = GNUNET_REST_create_response (result); | 331 | resp = GNUNET_REST_create_response (result); |
322 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); | 332 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); |