diff options
Diffstat (limited to 'src/reducer/anastasis_api_recovery_redux.c')
-rw-r--r-- | src/reducer/anastasis_api_recovery_redux.c | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/src/reducer/anastasis_api_recovery_redux.c b/src/reducer/anastasis_api_recovery_redux.c index 95632cc..c549d35 100644 --- a/src/reducer/anastasis_api_recovery_redux.c +++ b/src/reducer/anastasis_api_recovery_redux.c | |||
@@ -708,6 +708,90 @@ answer_feedback_cb ( | |||
708 | sctx->state); | 708 | sctx->state); |
709 | sctx_free (sctx); | 709 | sctx_free (sctx); |
710 | return; | 710 | return; |
711 | |||
712 | case ANASTASIS_CHALLENGE_STATUS_EXTERNAL_INSTRUCTIONS: | ||
713 | { | ||
714 | json_t *body = NULL; | ||
715 | const char *mime; | ||
716 | |||
717 | mime = csr->details.open_challenge.content_type; | ||
718 | if (0 == strcasecmp (mime, | ||
719 | "application/json")) | ||
720 | { | ||
721 | body = json_loadb (csr->details.open_challenge.body, | ||
722 | csr->details.open_challenge.body_size, | ||
723 | JSON_REJECT_DUPLICATES, | ||
724 | NULL); | ||
725 | GNUNET_break_op (NULL != body); | ||
726 | } | ||
727 | if (NULL == body) | ||
728 | { | ||
729 | json_t *err; | ||
730 | |||
731 | err = GNUNET_JSON_PACK ( | ||
732 | GNUNET_JSON_pack_string ("state", | ||
733 | "server-failure"), | ||
734 | GNUNET_JSON_pack_uint64 ("error_code", | ||
735 | TALER_EC_GENERIC_INVALID_RESPONSE)); | ||
736 | GNUNET_assert (0 == | ||
737 | json_object_set_new (feedback, | ||
738 | uuid, | ||
739 | err)); | ||
740 | } | ||
741 | else | ||
742 | { | ||
743 | const char *method; | ||
744 | json_t *details; | ||
745 | struct GNUNET_JSON_Specification spec[] = { | ||
746 | GNUNET_JSON_spec_string ("method", | ||
747 | &method), | ||
748 | GNUNET_JSON_spec_json ("details", | ||
749 | &details), | ||
750 | GNUNET_JSON_spec_end () | ||
751 | }; | ||
752 | json_t *reply; | ||
753 | |||
754 | if (GNUNET_OK != | ||
755 | GNUNET_JSON_parse (body, | ||
756 | spec, | ||
757 | NULL, NULL)) | ||
758 | { | ||
759 | json_t *err; | ||
760 | |||
761 | GNUNET_break_op (0); | ||
762 | err = GNUNET_JSON_PACK ( | ||
763 | GNUNET_JSON_pack_string ("state", | ||
764 | "server-failure"), | ||
765 | GNUNET_JSON_pack_uint64 ("error_code", | ||
766 | TALER_EC_GENERIC_REPLY_MALFORMED)); | ||
767 | GNUNET_assert (0 == | ||
768 | json_object_set_new (feedback, | ||
769 | uuid, | ||
770 | err)); | ||
771 | return; | ||
772 | } | ||
773 | |||
774 | reply = GNUNET_JSON_PACK ( | ||
775 | GNUNET_JSON_pack_string ("state", | ||
776 | "external-instructions"), | ||
777 | GNUNET_JSON_pack_string ("method", | ||
778 | method), | ||
779 | GNUNET_JSON_pack_object_incref ("details", | ||
780 | details)); | ||
781 | GNUNET_JSON_parse_free (spec); | ||
782 | GNUNET_assert (0 == | ||
783 | json_object_set_new (feedback, | ||
784 | uuid, | ||
785 | reply)); | ||
786 | } | ||
787 | } | ||
788 | set_state (sctx->state, | ||
789 | ANASTASIS_RECOVERY_STATE_CHALLENGE_SELECTING); | ||
790 | sctx->cb (sctx->cb_cls, | ||
791 | TALER_EC_NONE, | ||
792 | sctx->state); | ||
793 | sctx_free (sctx); | ||
794 | return; | ||
711 | } | 795 | } |
712 | GNUNET_break (0); | 796 | GNUNET_break (0); |
713 | ANASTASIS_redux_fail_ (sctx->cb, | 797 | ANASTASIS_redux_fail_ (sctx->cb, |