diff options
author | Phil <phil.buschmann@tum.de> | 2018-06-05 00:33:30 +0200 |
---|---|---|
committer | Phil <phil.buschmann@tum.de> | 2018-06-05 00:33:30 +0200 |
commit | f5aae6fb1455b197c54073d0be807b460268da6d (patch) | |
tree | b5651e52e6a22f973bcb3c71bb11ae92cc60e8be /src/identity | |
parent | bd01c63635f13a47bc295255e9485b785921f797 (diff) | |
download | gnunet-f5aae6fb1455b197c54073d0be807b460268da6d.tar.gz gnunet-f5aae6fb1455b197c54073d0be807b460268da6d.zip |
cleanup identity rest api, removed jsonapi includes
Diffstat (limited to 'src/identity')
-rw-r--r-- | src/identity/plugin_rest_identity.c | 96 |
1 files changed, 12 insertions, 84 deletions
diff --git a/src/identity/plugin_rest_identity.c b/src/identity/plugin_rest_identity.c index 49d7b58af..957a200b5 100644 --- a/src/identity/plugin_rest_identity.c +++ b/src/identity/plugin_rest_identity.c | |||
@@ -29,8 +29,6 @@ | |||
29 | #include "gnunet_rest_plugin.h" | 29 | #include "gnunet_rest_plugin.h" |
30 | #include "gnunet_identity_service.h" | 30 | #include "gnunet_identity_service.h" |
31 | #include "gnunet_rest_lib.h" | 31 | #include "gnunet_rest_lib.h" |
32 | #include "gnunet_jsonapi_lib.h" | ||
33 | #include "gnunet_jsonapi_util.h" | ||
34 | #include "microhttpd.h" | 32 | #include "microhttpd.h" |
35 | #include <jansson.h> | 33 | #include <jansson.h> |
36 | #include "gnunet_signatures.h" | 34 | #include "gnunet_signatures.h" |
@@ -53,23 +51,23 @@ | |||
53 | /** | 51 | /** |
54 | * Resource type | 52 | * Resource type |
55 | */ | 53 | */ |
56 | #define GNUNET_REST_JSONAPI_IDENTITY_EGO "ego" | 54 | #define GNUNET_REST_JSON_IDENTITY_EGO "ego" |
57 | 55 | ||
58 | /** | 56 | /** |
59 | * Name attribute | 57 | * Name attribute |
60 | */ | 58 | */ |
61 | #define GNUNET_REST_JSONAPI_IDENTITY_NAME "name" | 59 | #define GNUNET_REST_JSON_IDENTITY_NAME "name" |
62 | 60 | ||
63 | /** | 61 | /** |
64 | * Attribute to rename "name" TODO we changed id to the pubkey | 62 | * Attribute to rename "name" TODO we changed id to the pubkey |
65 | * so this can be unified with "name" | 63 | * so this can be unified with "name" |
66 | */ | 64 | */ |
67 | #define GNUNET_REST_JSONAPI_IDENTITY_NEWNAME "newname" | 65 | #define GNUNET_REST_JSON_IDENTITY_NEWNAME "newname" |
68 | 66 | ||
69 | /** | 67 | /** |
70 | * URL parameter to change the subsytem for ego | 68 | * URL parameter to change the subsytem for ego |
71 | */ | 69 | */ |
72 | #define GNUNET_REST_JSONAPI_IDENTITY_SUBSYSTEM "subsystem" | 70 | #define GNUNET_REST_JSON_IDENTITY_SUBSYSTEM "subsystem" |
73 | 71 | ||
74 | 72 | ||
75 | /** | 73 | /** |
@@ -329,7 +327,7 @@ get_ego_for_subsys (void *cls, | |||
329 | 327 | ||
330 | json_ego = json_object(); | 328 | json_ego = json_object(); |
331 | name_json = json_string (ego_entry->identifier); | 329 | name_json = json_string (ego_entry->identifier); |
332 | json_object_set_new(json_ego, GNUNET_REST_JSONAPI_IDENTITY_EGO, name_json); | 330 | json_object_set_new(json_ego, GNUNET_REST_JSON_IDENTITY_EGO, name_json); |
333 | json_array_append(json_root, json_ego); | 331 | json_array_append(json_root, json_ego); |
334 | 332 | ||
335 | break; | 333 | break; |
@@ -407,8 +405,8 @@ ego_info_response (struct GNUNET_REST_RequestHandle *con, | |||
407 | } | 405 | } |
408 | 406 | ||
409 | if ( NULL == egoname ) { | 407 | if ( NULL == egoname ) { |
410 | GNUNET_CRYPTO_hash (GNUNET_REST_JSONAPI_IDENTITY_SUBSYSTEM, | 408 | GNUNET_CRYPTO_hash (GNUNET_REST_JSON_IDENTITY_SUBSYSTEM, |
411 | strlen (GNUNET_REST_JSONAPI_IDENTITY_SUBSYSTEM), | 409 | strlen (GNUNET_REST_JSON_IDENTITY_SUBSYSTEM), |
412 | &key); | 410 | &key); |
413 | if ( GNUNET_YES == | 411 | if ( GNUNET_YES == |
414 | GNUNET_CONTAINER_multihashmap_contains (handle->conndata_handle->url_param_map, | 412 | GNUNET_CONTAINER_multihashmap_contains (handle->conndata_handle->url_param_map, |
@@ -442,7 +440,7 @@ ego_info_response (struct GNUNET_REST_RequestHandle *con, | |||
442 | json_ego = json_object(); | 440 | json_ego = json_object(); |
443 | 441 | ||
444 | json_object_set_new( json_ego, "id", json_string (ego_entry->keystring)); | 442 | json_object_set_new( json_ego, "id", json_string (ego_entry->keystring)); |
445 | json_object_set_new( json_ego, "type", json_string (GNUNET_REST_JSONAPI_IDENTITY_EGO)); | 443 | json_object_set_new( json_ego, "type", json_string (GNUNET_REST_JSON_IDENTITY_EGO)); |
446 | name_str = json_string (ego_entry->identifier); | 444 | name_str = json_string (ego_entry->identifier); |
447 | json_object_set_new( json_ego, "name", name_str); | 445 | json_object_set_new( json_ego, "name", name_str); |
448 | 446 | ||
@@ -496,76 +494,6 @@ do_finished (void *cls, const char *emsg) | |||
496 | cleanup_handle (handle); | 494 | cleanup_handle (handle); |
497 | } | 495 | } |
498 | 496 | ||
499 | // | ||
500 | // | ||
501 | ///** | ||
502 | // * Parse given JSON object to jsonapi document. | ||
503 | // * | ||
504 | // * @param cls closure, NULL | ||
505 | // * @param root the json object representing data | ||
506 | // * @param[out] spec where to write the data | ||
507 | // * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error | ||
508 | // */ | ||
509 | //static int | ||
510 | //parse_jsonapiobject (void *cls, json_t *root, | ||
511 | // struct GNUNET_JSON_Specification *spec) | ||
512 | //{ | ||
513 | // if (NULL == root) | ||
514 | // { | ||
515 | // return GNUNET_SYSERR; | ||
516 | // } | ||
517 | // if (1 == json_is_object(root)) | ||
518 | // { | ||
519 | // if (1 == json_is_string(json_object_get (root, GNUNET_REST_JSONAPI_IDENTITY_NAME))) | ||
520 | // { | ||
521 | // return GNUNET_OK; | ||
522 | // } | ||
523 | // } | ||
524 | // return GNUNET_SYSERR; | ||
525 | //} | ||
526 | // | ||
527 | ///** | ||
528 | // * Cleanup data left from parsing RSA public key. | ||
529 | // * | ||
530 | // * @param cls closure, NULL | ||
531 | // * @param[out] spec where to free the data | ||
532 | // */ | ||
533 | //static void | ||
534 | //clean_jsonapiobject (void *cls, | ||
535 | // struct GNUNET_JSON_Specification *spec) | ||
536 | //{ | ||
537 | // json_t **jsonapi_obj = (json_t **) spec->ptr; | ||
538 | // if (NULL != *jsonapi_obj) | ||
539 | // { | ||
540 | // json_decref (*jsonapi_obj); | ||
541 | // *jsonapi_obj = NULL; | ||
542 | // } | ||
543 | //} | ||
544 | // | ||
545 | ///** | ||
546 | // * JSON object. | ||
547 | // * | ||
548 | // * @param name name of the JSON field | ||
549 | // * @param[out] jsonp where to store the JSON found under @a name | ||
550 | // */ | ||
551 | //struct GNUNET_JSON_Specification | ||
552 | //GNUNET_JSON_spec_json_create_identity (json_t **jsonapi_object) | ||
553 | //{ | ||
554 | // struct GNUNET_JSON_Specification ret = { | ||
555 | // .parser = &parse_jsonapiobject, | ||
556 | // .cleaner = &clean_jsonapiobject, | ||
557 | // .cls = NULL, | ||
558 | // .field = NULL, | ||
559 | // .ptr = jsonapi_object, | ||
560 | // .ptr_size = 0, | ||
561 | // .size_ptr = NULL | ||
562 | // }; | ||
563 | // *jsonapi_object = NULL; | ||
564 | // return ret; | ||
565 | //} | ||
566 | |||
567 | |||
568 | |||
569 | /** | 497 | /** |
570 | * Create a new ego | 498 | * Create a new ego |
571 | * | 499 | * |
@@ -630,7 +558,7 @@ ego_create_cont (struct GNUNET_REST_RequestHandle *con, | |||
630 | return; | 558 | return; |
631 | } | 559 | } |
632 | 560 | ||
633 | egoname_json = json_object_get (data_js, GNUNET_REST_JSONAPI_IDENTITY_NAME); | 561 | egoname_json = json_object_get (data_js, GNUNET_REST_JSON_IDENTITY_NAME); |
634 | if (!json_is_string (egoname_json)) | 562 | if (!json_is_string (egoname_json)) |
635 | { | 563 | { |
636 | json_decref (data_js); | 564 | json_decref (data_js); |
@@ -757,7 +685,7 @@ ego_edit_cont (struct GNUNET_REST_RequestHandle *con, | |||
757 | } | 685 | } |
758 | 686 | ||
759 | //This is a rename | 687 | //This is a rename |
760 | name_json = json_object_get (data_js, GNUNET_REST_JSONAPI_IDENTITY_NEWNAME); | 688 | name_json = json_object_get (data_js, GNUNET_REST_JSON_IDENTITY_NEWNAME); |
761 | if ((NULL != name_json) && json_is_string (name_json)) | 689 | if ((NULL != name_json) && json_is_string (name_json)) |
762 | { | 690 | { |
763 | newname = json_string_value (name_json); | 691 | newname = json_string_value (name_json); |
@@ -794,7 +722,7 @@ ego_edit_cont (struct GNUNET_REST_RequestHandle *con, | |||
794 | } | 722 | } |
795 | 723 | ||
796 | //Set subsystem | 724 | //Set subsystem |
797 | subsys_json = json_object_get (data_js, GNUNET_REST_JSONAPI_IDENTITY_SUBSYSTEM); | 725 | subsys_json = json_object_get (data_js, GNUNET_REST_JSON_IDENTITY_SUBSYSTEM); |
798 | if ( (NULL != subsys_json) && json_is_string (subsys_json)) | 726 | if ( (NULL != subsys_json) && json_is_string (subsys_json)) |
799 | { | 727 | { |
800 | subsys = json_string_value (subsys_json); | 728 | subsys = json_string_value (subsys_json); |
@@ -914,7 +842,7 @@ init_cont (struct RequestHandle *handle) | |||
914 | GNUNET_REST_HANDLER_END | 842 | GNUNET_REST_HANDLER_END |
915 | }; | 843 | }; |
916 | 844 | ||
917 | if (GNUNET_NO == GNUNET_JSONAPI_handle_request (handle->conndata_handle, | 845 | if (GNUNET_NO == GNUNET_REST_handle_request (handle->conndata_handle, |
918 | handlers, | 846 | handlers, |
919 | &err, | 847 | &err, |
920 | handle)) | 848 | handle)) |