aboutsummaryrefslogtreecommitdiff
path: root/src/reclaim/plugin_rest_pabc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/reclaim/plugin_rest_pabc.c')
-rw-r--r--src/reclaim/plugin_rest_pabc.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/reclaim/plugin_rest_pabc.c b/src/reclaim/plugin_rest_pabc.c
index 1c766a716..9c1ac3c47 100644
--- a/src/reclaim/plugin_rest_pabc.c
+++ b/src/reclaim/plugin_rest_pabc.c
@@ -264,9 +264,8 @@ set_attributes_from_idtoken (const struct pabc_context *ctx,
264 json_string_value (value)); 264 json_string_value (value));
265 if (PABC_OK != status) 265 if (PABC_OK != status)
266 { 266 {
267 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 267 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
268 "Failed to set attribute.\n"); 268 "Failed to set attribute `%s'.\n", key);
269 return PABC_FAILURE;
270 } 269 }
271 } 270 }
272 return PABC_OK; 271 return PABC_OK;
@@ -370,7 +369,7 @@ cr_cont (struct GNUNET_REST_RequestHandle *con_handle,
370 GNUNET_SCHEDULER_add_now (&do_error, handle); 369 GNUNET_SCHEDULER_add_now (&do_error, handle);
371 return; 370 return;
372 } 371 }
373 idtoken_json = json_object_get (idtoken_json, "id_token"); 372 idtoken_json = json_object_get (data_json, "id_token");
374 if (NULL == idtoken_json) 373 if (NULL == idtoken_json)
375 { 374 {
376 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 375 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -390,13 +389,18 @@ cr_cont (struct GNUNET_REST_RequestHandle *con_handle,
390 } 389 }
391 390
392 PABC_ASSERT (pabc_new_ctx (&ctx)); 391 PABC_ASSERT (pabc_new_ctx (&ctx));
393 // FIXME jansson does stupid escaping here maybe expect ecoded? 392 char *pp_str = json_dumps (pp_json, JSON_ENCODE_ANY);
394 status = pabc_decode_and_new_public_parameters (ctx, 393 status = pabc_decode_and_new_public_parameters (ctx,
395 &pp, 394 &pp,
396 json_string_value (pp_json)); 395 pp_str);
396 char *ppid;
397 GNUNET_assert (PABC_OK == pabc_cred_get_ppid_from_pp (pp_str, &ppid));
398 GNUNET_free (pp_str);
397 if (status != PABC_OK) 399 if (status != PABC_OK)
398 { 400 {
399 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to read public parameters.\n"); 401 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
402 "Failed to read public parameters: %s\n",
403 pp_str);
400 json_decref (data_json); 404 json_decref (data_json);
401 GNUNET_SCHEDULER_add_now (&do_error, handle); 405 GNUNET_SCHEDULER_add_now (&do_error, handle);
402 return; 406 return;
@@ -457,8 +461,8 @@ cr_cont (struct GNUNET_REST_RequestHandle *con_handle,
457 GNUNET_SCHEDULER_add_now (&do_error, handle); 461 GNUNET_SCHEDULER_add_now (&do_error, handle);
458 return; 462 return;
459 } 463 }
460 // FIXME: where does this come from??? 464 char *nonce_str = json_dumps (nonce_json, JSON_ENCODE_ANY);
461 status = pabc_decode_nonce (ctx, nonce, json_string_value (nonce_json)); 465 status = pabc_decode_nonce (ctx, nonce, nonce_str);
462 if (status != PABC_OK) 466 if (status != PABC_OK)
463 { 467 {
464 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to decode nonce.\n"); 468 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to decode nonce.\n");
@@ -496,7 +500,9 @@ cr_cont (struct GNUNET_REST_RequestHandle *con_handle,
496 return; 500 return;
497 } 501 }
498 handle->resp_object = json_object (); 502 handle->resp_object = json_object ();
499 pabc_encode_credential_request (ctx, pp, cr, &response_str); 503 GNUNET_assert (PABC_OK == pabc_cred_encode_cr (ctx, pp, cr,
504 json_string_value (identity_json),
505 ppid, &response_str));
500 if (PABC_OK != status) 506 if (PABC_OK != status)
501 { 507 {
502 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to serialize cr.\n"); 508 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to serialize cr.\n");
@@ -508,9 +514,9 @@ cr_cont (struct GNUNET_REST_RequestHandle *con_handle,
508 GNUNET_SCHEDULER_add_now (&do_error, handle); 514 GNUNET_SCHEDULER_add_now (&do_error, handle);
509 return; 515 return;
510 } 516 }
517 json_decref (handle->resp_object);
518 handle->resp_object = json_loads (response_str, JSON_DECODE_ANY, &err);
511 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s\n", response_str); 519 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s\n", response_str);
512 json_object_set_new (handle->resp_object, "cr",
513 json_string (response_str));
514 GNUNET_free (response_str); 520 GNUNET_free (response_str);
515 521
516 // clean up 522 // clean up
@@ -593,7 +599,7 @@ rest_identity_process_request (struct GNUNET_REST_RequestHandle *rest_handle,
593 * @return NULL on error, otherwise the plugin context 599 * @return NULL on error, otherwise the plugin context
594 */ 600 */
595void * 601void *
596libgnunet_plugin_rest_reclaim_init (void *cls) 602libgnunet_plugin_rest_pabc_init (void *cls)
597{ 603{
598 static struct Plugin plugin; 604 static struct Plugin plugin;
599 struct GNUNET_REST_Plugin *api; 605 struct GNUNET_REST_Plugin *api;