aboutsummaryrefslogtreecommitdiff
path: root/src/identity-provider
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2016-05-02 16:32:36 +0000
committerMartin Schanzenbach <mschanzenbach@posteo.de>2016-05-02 16:32:36 +0000
commitbee208bcd6803829aa26c55a4c8e176a5f2c815f (patch)
tree6974bc9e94a1ec938b5376d2631233d2e75baf7d /src/identity-provider
parentfc9b25be2dbe5392501dbc0b6659c1aa50809bc2 (diff)
downloadgnunet-bee208bcd6803829aa26c55a4c8e176a5f2c815f.tar.gz
gnunet-bee208bcd6803829aa26c55a4c8e176a5f2c815f.zip
- Refactor jsonapi into separate module
Diffstat (limited to 'src/identity-provider')
-rw-r--r--src/identity-provider/Makefile.am1
-rw-r--r--src/identity-provider/identity_token.c2
-rw-r--r--src/identity-provider/plugin_rest_identity_provider.c33
3 files changed, 19 insertions, 17 deletions
diff --git a/src/identity-provider/Makefile.am b/src/identity-provider/Makefile.am
index 4ba2f4700..ca224b860 100644
--- a/src/identity-provider/Makefile.am
+++ b/src/identity-provider/Makefile.am
@@ -58,6 +58,7 @@ libgnunet_plugin_rest_identity_provider_la_LIBADD = \
58 $(top_builddir)/src/identity/libgnunetidentity.la \ 58 $(top_builddir)/src/identity/libgnunetidentity.la \
59 libgnunetidentityprovider.la \ 59 libgnunetidentityprovider.la \
60 $(top_builddir)/src/rest/libgnunetrest.la \ 60 $(top_builddir)/src/rest/libgnunetrest.la \
61 $(top_builddir)/src/jsonapi/libgnunetjsonapi.la \
61 $(top_builddir)/src/namestore/libgnunetnamestore.la \ 62 $(top_builddir)/src/namestore/libgnunetnamestore.la \
62 $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) \ 63 $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) \
63 $(LTLIBINTL) -ljansson -lmicrohttpd 64 $(LTLIBINTL) -ljansson -lmicrohttpd
diff --git a/src/identity-provider/identity_token.c b/src/identity-provider/identity_token.c
index 958597630..3bed6962e 100644
--- a/src/identity-provider/identity_token.c
+++ b/src/identity-provider/identity_token.c
@@ -629,7 +629,7 @@ ticket_payload_serialize (struct TokenTicketPayload *payload,
629 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); 629 sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey));
630 630
631 GNUNET_asprintf (result, 631 GNUNET_asprintf (result,
632 "{\"nonce\": \""SCNu64"\",\"identity\": \"%s\",\"label\": \"%s\"}", 632 "{\"nonce\": \"%"SCNu64"\",\"identity\": \"%s\",\"label\": \"%s\"}",
633 payload->nonce, identity_key_str, payload->label); 633 payload->nonce, identity_key_str, payload->label);
634 GNUNET_free (identity_key_str); 634 GNUNET_free (identity_key_str);
635 635
diff --git a/src/identity-provider/plugin_rest_identity_provider.c b/src/identity-provider/plugin_rest_identity_provider.c
index 376110a6d..1f03713ea 100644
--- a/src/identity-provider/plugin_rest_identity_provider.c
+++ b/src/identity-provider/plugin_rest_identity_provider.c
@@ -31,6 +31,7 @@
31#include "gnunet_gnsrecord_lib.h" 31#include "gnunet_gnsrecord_lib.h"
32#include "gnunet_namestore_service.h" 32#include "gnunet_namestore_service.h"
33#include "gnunet_rest_lib.h" 33#include "gnunet_rest_lib.h"
34#include "gnunet_jsonapi_lib.h"
34#include "microhttpd.h" 35#include "microhttpd.h"
35#include <jansson.h> 36#include <jansson.h>
36#include <inttypes.h> 37#include <inttypes.h>
@@ -273,7 +274,7 @@ struct RequestHandle
273 /** 274 /**
274 * Response object 275 * Response object
275 */ 276 */
276 struct JsonApiObject *resp_object; 277 struct GNUNET_JSONAPI_Object *resp_object;
277 278
278}; 279};
279 280
@@ -290,7 +291,7 @@ cleanup_handle (struct RequestHandle *handle)
290 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 291 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
291 "Cleaning up\n"); 292 "Cleaning up\n");
292 if (NULL != handle->resp_object) 293 if (NULL != handle->resp_object)
293 GNUNET_REST_jsonapi_object_delete (handle->resp_object); 294 GNUNET_JSONAPI_object_delete (handle->resp_object);
294 if (NULL != handle->timeout_task) 295 if (NULL != handle->timeout_task)
295 GNUNET_SCHEDULER_cancel (handle->timeout_task); 296 GNUNET_SCHEDULER_cancel (handle->timeout_task);
296 if (NULL != handle->identity_handle) 297 if (NULL != handle->identity_handle)
@@ -381,7 +382,7 @@ token_creat_cont (void *cls,
381 const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket, 382 const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket,
382 const struct GNUNET_IDENTITY_PROVIDER_Token *token) 383 const struct GNUNET_IDENTITY_PROVIDER_Token *token)
383{ 384{
384 struct JsonApiResource *json_resource; 385 struct GNUNET_JSONAPI_Resource *json_resource;
385 struct RequestHandle *handle = cls; 386 struct RequestHandle *handle = cls;
386 struct MHD_Response *resp; 387 struct MHD_Response *resp;
387 json_t *ticket_json; 388 json_t *ticket_json;
@@ -397,26 +398,26 @@ token_creat_cont (void *cls,
397 return; 398 return;
398 } 399 }
399 400
400 handle->resp_object = GNUNET_REST_jsonapi_object_new (); 401 handle->resp_object = GNUNET_JSONAPI_object_new ();
401 json_resource = GNUNET_REST_jsonapi_resource_new (GNUNET_REST_JSONAPI_IDENTITY_PROVIDER_TICKET, 402 json_resource = GNUNET_JSONAPI_resource_new (GNUNET_REST_JSONAPI_IDENTITY_PROVIDER_TICKET,
402 label); 403 label);
403 ticket_str = GNUNET_IDENTITY_PROVIDER_ticket_to_string (ticket); 404 ticket_str = GNUNET_IDENTITY_PROVIDER_ticket_to_string (ticket);
404 token_str = GNUNET_IDENTITY_PROVIDER_token_to_string (token); 405 token_str = GNUNET_IDENTITY_PROVIDER_token_to_string (token);
405 ticket_json = json_string (ticket_str); 406 ticket_json = json_string (ticket_str);
406 token_json = json_string (token_str); 407 token_json = json_string (token_str);
407 GNUNET_REST_jsonapi_resource_add_attr (json_resource, 408 GNUNET_JSONAPI_resource_add_attr (json_resource,
408 GNUNET_REST_JSONAPI_IDENTITY_PROVIDER_TICKET, 409 GNUNET_REST_JSONAPI_IDENTITY_PROVIDER_TICKET,
409 ticket_json); 410 ticket_json);
410 GNUNET_REST_jsonapi_resource_add_attr (json_resource, 411 GNUNET_JSONAPI_resource_add_attr (json_resource,
411 GNUNET_REST_JSONAPI_IDENTITY_PROVIDER_TOKEN, 412 GNUNET_REST_JSONAPI_IDENTITY_PROVIDER_TOKEN,
412 token_json); 413 token_json);
413 GNUNET_free (ticket_str); 414 GNUNET_free (ticket_str);
414 GNUNET_free (token_str); 415 GNUNET_free (token_str);
415 json_decref (ticket_json); 416 json_decref (ticket_json);
416 json_decref (token_json); 417 json_decref (token_json);
417 GNUNET_REST_jsonapi_object_resource_add (handle->resp_object, json_resource); 418 GNUNET_JSONAPI_object_resource_add (handle->resp_object, json_resource);
418 419
419 GNUNET_REST_jsonapi_data_serialize (handle->resp_object, &result_str); 420 GNUNET_JSONAPI_data_serialize (handle->resp_object, &result_str);
420 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str); 421 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str);
421 resp = GNUNET_REST_create_json_response (result_str); 422 resp = GNUNET_REST_create_json_response (result_str);
422 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); 423 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
@@ -632,7 +633,7 @@ return_token_list (void *cls)
632 struct RequestHandle *handle = cls; 633 struct RequestHandle *handle = cls;
633 struct MHD_Response *resp; 634 struct MHD_Response *resp;
634 635
635 GNUNET_REST_jsonapi_data_serialize (handle->resp_object, &result_str); 636 GNUNET_JSONAPI_data_serialize (handle->resp_object, &result_str);
636 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str); 637 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str);
637 resp = GNUNET_REST_create_json_response (result_str); 638 resp = GNUNET_REST_create_json_response (result_str);
638 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); 639 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
@@ -657,7 +658,7 @@ token_collect (void *cls,
657 char* data; 658 char* data;
658 struct RequestHandle *handle = cls; 659 struct RequestHandle *handle = cls;
659 struct EgoEntry *ego_tmp; 660 struct EgoEntry *ego_tmp;
660 struct JsonApiResource *json_resource; 661 struct GNUNET_JSONAPI_Resource *json_resource;
661 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key; 662 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key;
662 json_t *issuer; 663 json_t *issuer;
663 json_t *token; 664 json_t *token;
@@ -698,20 +699,20 @@ token_collect (void *cls,
698 rd[i].data, 699 rd[i].data,
699 rd[i].data_size); 700 rd[i].data_size);
700 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding token: %s\n", data); 701 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding token: %s\n", data);
701 json_resource = GNUNET_REST_jsonapi_resource_new (GNUNET_REST_JSONAPI_IDENTITY_TOKEN, 702 json_resource = GNUNET_JSONAPI_resource_new (GNUNET_REST_JSONAPI_IDENTITY_TOKEN,
702 label); 703 label);
703 issuer = json_string (handle->ego_head->identifier); 704 issuer = json_string (handle->ego_head->identifier);
704 GNUNET_REST_jsonapi_resource_add_attr (json_resource, 705 GNUNET_JSONAPI_resource_add_attr (json_resource,
705 GNUNET_REST_JSONAPI_IDENTITY_ISS_REQUEST, 706 GNUNET_REST_JSONAPI_IDENTITY_ISS_REQUEST,
706 issuer); 707 issuer);
707 json_decref (issuer); 708 json_decref (issuer);
708 token = json_string (data); 709 token = json_string (data);
709 GNUNET_REST_jsonapi_resource_add_attr (json_resource, 710 GNUNET_JSONAPI_resource_add_attr (json_resource,
710 GNUNET_REST_JSONAPI_IDENTITY_TOKEN, 711 GNUNET_REST_JSONAPI_IDENTITY_TOKEN,
711 token); 712 token);
712 json_decref (token); 713 json_decref (token);
713 714
714 GNUNET_REST_jsonapi_object_resource_add (handle->resp_object, json_resource); 715 GNUNET_JSONAPI_object_resource_add (handle->resp_object, json_resource);
715 GNUNET_free (data); 716 GNUNET_free (data);
716 } 717 }
717 } 718 }
@@ -770,7 +771,7 @@ list_token_cont (struct RestConnectionDataHandle *con_handle,
770 GNUNET_free (ego_tmp); 771 GNUNET_free (ego_tmp);
771 } 772 }
772 } 773 }
773 handle->resp_object = GNUNET_REST_jsonapi_object_new (); 774 handle->resp_object = GNUNET_JSONAPI_object_new ();
774 if (NULL == handle->ego_head) 775 if (NULL == handle->ego_head)
775 { 776 {
776 //Done 777 //Done