GNUnet 0.21.2
reclaim_plugin.c
Go to the documentation of this file.
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2012-2015 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
27#include "platform.h"
28#include "gnunet_json_lib.h"
29#include "microhttpd.h"
30#include <inttypes.h>
31#include <jansson.h>
32#include "gnunet_gns_service.h"
35#include "gnunet_reclaim_lib.h"
37#include "gnunet_rest_lib.h"
38#include "gnunet_rest_plugin.h"
39#include "gnunet_signatures.h"
40#include "json_reclaim.h"
44#define GNUNET_REST_API_NS_RECLAIM "/reclaim"
45
49#define GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES "/reclaim/attributes"
50
54#define GNUNET_REST_API_NS_RECLAIM_CREDENTIAL "/reclaim/credential"
55
59#define GNUNET_REST_API_NS_IDENTITY_TICKETS "/reclaim/tickets"
60
64#define GNUNET_REST_API_NS_IDENTITY_REVOKE "/reclaim/revoke"
65
69#define GNUNET_REST_API_NS_IDENTITY_CONSUME "/reclaim/consume"
70
74#define ID_REST_STATE_INIT 0
75
79#define ID_REST_STATE_POST_INIT 1
80
85
89static char *allow_methods;
90
94static struct EgoEntry *ego_head;
95
99static struct EgoEntry *ego_tail;
100
104static int state;
105
110
115
119struct Plugin
120{
121 const struct GNUNET_CONFIGURATION_Handle *cfg;
122};
123
127struct EgoEntry
128{
132 struct EgoEntry *next;
133
137 struct EgoEntry *prev;
138
142 char *identifier;
143
147 char *keystring;
148
152 struct GNUNET_IDENTITY_Ego *ego;
153};
154
155
156struct RequestHandle
157{
161 struct RequestHandle *next;
162
166 struct RequestHandle *prev;
167
171 struct EgoEntry *ego_entry;
172
177
182
187
192
197
202
207
212
217
222
227
232
236 void *proc_cls;
237
241 char *url;
242
246 char *emsg;
247
251 int response_code;
252
256 json_t *resp_object;
257};
258
263
268
269
274static void
275cleanup_handle (void *cls)
276{
277 struct RequestHandle *handle = cls;
278
279 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n");
280 if (NULL != handle->resp_object)
281 json_decref (handle->resp_object);
282 if (NULL != handle->timeout_task)
283 GNUNET_SCHEDULER_cancel (handle->timeout_task);
284 if (NULL != handle->attr_it)
286 if (NULL != handle->cred_it)
288 if (NULL != handle->ticket_it)
290 if (NULL != handle->url)
291 GNUNET_free (handle->url);
292 if (NULL != handle->emsg)
293 GNUNET_free (handle->emsg);
294 if (NULL != handle->attr_list)
298 handle);
300}
301
302
308static void
309do_error (void *cls)
310{
311 struct RequestHandle *handle = cls;
312 struct MHD_Response *resp;
313 char *json_error;
314
315 GNUNET_asprintf (&json_error, "{ \"error\" : \"%s\" }", handle->emsg);
316 if (0 == handle->response_code)
317 {
318 handle->response_code = MHD_HTTP_BAD_REQUEST;
319 }
320 resp = GNUNET_REST_create_response (json_error);
321 GNUNET_assert (MHD_NO != MHD_add_response_header (resp, "Content-Type",
322 "application/json"));
323 handle->proc (handle->proc_cls, resp, handle->response_code);
325 GNUNET_free (json_error);
326}
327
328
334static void
335do_timeout (void *cls)
336{
337 struct RequestHandle *handle = cls;
338
339 handle->timeout_task = NULL;
341}
342
343
344static void
346{
348}
349
350
351static void
352finished_cont (void *cls, int32_t success, const char *emsg)
353{
354 struct RequestHandle *handle = cls;
355 struct MHD_Response *resp;
356
357 handle->idp_op = NULL;
358 if (GNUNET_OK != success)
359 {
361 return;
362 }
363 resp = GNUNET_REST_create_response (emsg);
364 GNUNET_assert (MHD_NO != MHD_add_response_header (resp,
365 "Content-Type",
366 "application/json"));
367 GNUNET_assert (MHD_NO != MHD_add_response_header (resp,
368 "Access-Control-Allow-Methods",
370 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
372}
373
374
375static void
376delete_finished_cb (void *cls, int32_t success, const char *emsg)
377{
378 struct RequestHandle *handle = cls;
379 struct MHD_Response *resp;
380
381 if (GNUNET_OK != success)
382 {
384 return;
385 }
386 resp = GNUNET_REST_create_response (emsg);
387 GNUNET_assert (MHD_NO != MHD_add_response_header (resp,
388 "Access-Control-Allow-Methods",
390 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
392}
393
394
400static void
402{
403 char *result_str;
404 struct RequestHandle *handle = cls;
405 struct MHD_Response *resp;
406
407 result_str = json_dumps (handle->resp_object, 0);
408 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str);
409 resp = GNUNET_REST_create_response (result_str);
410 GNUNET_assert (MHD_NO !=
411 MHD_add_response_header (resp,
412 "Access-Control-Allow-Methods",
414 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
415 GNUNET_free (result_str);
417}
418
419
420static void
422{
423 struct RequestHandle *handle = cls;
424
425 // Done
426 handle->attr_it = NULL;
427 handle->cred_it = NULL;
428 handle->ticket_it = NULL;
430}
431
432
437static void
439 const char *rp_uri)
440{
441 json_t *json_resource;
442 struct RequestHandle *handle = cls;
443
444 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding ticket\n");
445 json_resource = json_object ();
446 json_array_append (handle->resp_object, json_resource);
447
448 json_object_set_new (json_resource, "gns_name", json_string (ticket->gns_name)
449 );
450 json_object_set_new (json_resource, "rp_uri", json_string (rp_uri));
452}
453
454
455static void
457 const char *url,
458 void *cls)
459{
460 struct RequestHandle *handle = cls;
461 const struct GNUNET_CRYPTO_PrivateKey *identity_priv;
462 const char *identity;
463 struct EgoEntry *ego_entry;
464 struct GNUNET_RECLAIM_Credential *attribute;
465 struct GNUNET_TIME_Relative exp;
466 char term_data[handle->rest_handle->data_size + 1];
467 json_t *data_json;
468 json_error_t err;
469 struct GNUNET_JSON_Specification attrspec[] =
472
474 "Adding an credential for %s.\n",
475 handle->url);
476 if (strlen (GNUNET_REST_API_NS_RECLAIM_CREDENTIAL) >= strlen (
477 handle->url))
478 {
479 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
481 return;
482 }
483 identity = handle->url + strlen (
485
486 for (ego_entry = ego_head; NULL != ego_entry;
487 ego_entry = ego_entry->next)
488 if (0 == strcmp (identity, ego_entry->identifier))
489 break;
490
491 if (NULL == ego_entry)
492 {
493 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Identity unknown (%s)\n", identity);
494 return;
495 }
496 identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
497
498 if (0 >= handle->rest_handle->data_size)
499 {
501 return;
502 }
503
504 term_data[handle->rest_handle->data_size] = '\0';
505 GNUNET_memcpy (term_data,
506 handle->rest_handle->data,
507 handle->rest_handle->data_size);
508 data_json = json_loads (term_data, JSON_DECODE_ANY, &err);
509 if (GNUNET_OK != GNUNET_JSON_parse (data_json, attrspec, NULL, NULL))
510 {
511 json_decref (data_json);
513 "Unable to parse JSON from %s\n",
514 term_data);
516 return;
517 }
518 json_decref (data_json);
519 if (NULL == attribute)
520 {
522 "Unable to parse credential from %s\n",
523 term_data);
525 return;
526 }
530 if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&attribute->id))
531 GNUNET_RECLAIM_id_generate (&attribute->id);
534 identity_priv,
535 attribute,
536 &exp,
538 handle);
539 GNUNET_JSON_parse_free (attrspec);
540}
541
542
547static void
549 const struct GNUNET_CRYPTO_PublicKey *identity,
550 const struct GNUNET_RECLAIM_Credential *cred)
551{
552 struct RequestHandle *handle = cls;
553 struct GNUNET_RECLAIM_AttributeList *attrs;
555 struct GNUNET_TIME_Absolute exp;
556 json_t *attr_obj;
557 json_t *cred_obj;
558 const char *type;
559 char *tmp_value;
560 char *id_str;
561 char *issuer;
562
563
564 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding credential: %s\n",
565 cred->name);
569 cred->data,
570 cred->data_size);
571 cred_obj = json_object ();
572 json_object_set_new (cred_obj, "value", json_string (tmp_value));
573 json_object_set_new (cred_obj, "name", json_string (cred->name));
575 json_object_set_new (cred_obj, "type", json_string (type));
576 if (NULL != issuer)
577 {
578 json_object_set_new (cred_obj, "issuer", json_string (issuer));
579 GNUNET_free (issuer);
580 }
582 &exp))
583 {
584 json_object_set_new (cred_obj, "expiration", json_integer (
585 exp.abs_value_us));
586 }
588 sizeof(cred->id));
589 json_object_set_new (cred_obj, "id", json_string (id_str));
590 GNUNET_free (tmp_value);
591 GNUNET_free (id_str);
592 if (NULL != attrs)
593 {
594 json_t *attr_arr = json_array ();
595 for (ale = attrs->list_head; NULL != ale; ale = ale->next)
596 {
597 tmp_value =
599 ale->attribute->data,
600 ale->attribute->data_size);
601 attr_obj = json_object ();
602 json_object_set_new (attr_obj, "value", json_string (tmp_value));
603 json_object_set_new (attr_obj, "name", json_string (
604 ale->attribute->name));
605
606 json_object_set_new (attr_obj, "flag", json_string ("1")); // FIXME
608 json_object_set_new (attr_obj, "type", json_string (type));
609 json_object_set_new (attr_obj, "id", json_string (""));
610 json_object_set_new (attr_obj, "credential", json_string (""));
611 json_array_append_new (attr_arr, attr_obj);
612 GNUNET_free (tmp_value);
613 }
614 json_object_set_new (cred_obj, "attributes", attr_arr);
615 }
616 json_array_append_new (handle->resp_object, cred_obj);
617 if (NULL != attrs)
620}
621
622
630static void
632 const char *url,
633 void *cls)
634{
635 struct RequestHandle *handle = cls;
636 const struct GNUNET_CRYPTO_PrivateKey *priv_key;
637 struct EgoEntry *ego_entry;
638 char *identity;
639
641 "Getting credentials for %s.\n",
642 handle->url);
643 if (strlen (GNUNET_REST_API_NS_RECLAIM_CREDENTIAL) >= strlen (
644 handle->url))
645 {
646 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
648 return;
649 }
650 identity = handle->url + strlen (
652
653 for (ego_entry = ego_head; NULL != ego_entry;
654 ego_entry = ego_entry->next)
655 if (0 == strcmp (identity, ego_entry->identifier))
656 break;
657 handle->resp_object = json_array ();
658
659
660 if (NULL == ego_entry)
661 {
662 // Done
663 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
665 return;
666 }
667 priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
669 priv_key,
671 handle,
673 handle,
674 &
676 handle);
677}
678
679
687static void
689 const char *url,
690 void *cls)
691{
692 struct RequestHandle *handle = cls;
693 const struct GNUNET_CRYPTO_PrivateKey *priv_key;
694 struct GNUNET_RECLAIM_Credential attr;
695 struct EgoEntry *ego_entry;
696 char *identity_id_str;
697 char *identity;
698 char *id;
699
700 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting credential.\n");
701 if (strlen (GNUNET_REST_API_NS_RECLAIM_CREDENTIAL) >= strlen (
702 handle->url))
703 {
704 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
706 return;
707 }
708 identity_id_str =
709 strdup (handle->url + strlen (
711 identity = strtok (identity_id_str, "/");
712 id = strtok (NULL, "/");
713 if ((NULL == identity) || (NULL == id))
714 {
715 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Malformed request.\n");
716 GNUNET_free (identity_id_str);
718 return;
719 }
720
721 for (ego_entry = ego_head; NULL != ego_entry;
722 ego_entry = ego_entry->next)
723 if (0 == strcmp (identity, ego_entry->identifier))
724 break;
725 handle->resp_object = json_array ();
726 if (NULL == ego_entry)
727 {
728 // Done
729 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
730 GNUNET_free (identity_id_str);
732 return;
733 }
734 priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
735 memset (&attr, 0, sizeof(struct GNUNET_RECLAIM_Credential));
736 GNUNET_STRINGS_string_to_data (id, strlen (id), &attr.id, sizeof(attr.id));
737 attr.name = "";
739 priv_key,
740 &attr,
742 handle);
743 GNUNET_free (identity_id_str);
744}
745
746
754static void
756 const char *url,
757 void *cls)
758{
759 const struct GNUNET_CRYPTO_PrivateKey *priv_key;
760 struct RequestHandle *handle = cls;
761 struct EgoEntry *ego_entry;
762 char *identity;
763
765 "Getting tickets for %s.\n",
766 handle->url);
767 if (strlen (GNUNET_REST_API_NS_IDENTITY_TICKETS) >= strlen (handle->url))
768 {
769 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
771 return;
772 }
774
775 for (ego_entry = ego_head; NULL != ego_entry;
776 ego_entry = ego_entry->next)
777 if (0 == strcmp (identity, ego_entry->identifier))
778 break;
779 handle->resp_object = json_array ();
780
781 if (NULL == ego_entry)
782 {
783 // Done
784 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
786 return;
787 }
788 priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
789 handle->ticket_it =
791 priv_key,
793 handle,
795 handle,
797 handle);
798}
799
800
801static void
803 const char *url,
804 void *cls)
805{
806 const struct GNUNET_CRYPTO_PrivateKey *identity_priv;
807 const char *identity;
808 struct RequestHandle *handle = cls;
809 struct EgoEntry *ego_entry;
810 struct GNUNET_RECLAIM_Attribute *attribute;
811 struct GNUNET_TIME_Relative exp;
812 char term_data[handle->rest_handle->data_size + 1];
813 json_t *data_json;
814 json_error_t err;
815 struct GNUNET_JSON_Specification attrspec[] =
817
819 "Adding an attribute for %s.\n",
820 handle->url);
821 if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) >= strlen (handle->url))
822 {
823 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
825 return;
826 }
828
829 for (ego_entry = ego_head; NULL != ego_entry;
830 ego_entry = ego_entry->next)
831 if (0 == strcmp (identity, ego_entry->identifier))
832 break;
833
834 if (NULL == ego_entry)
835 {
836 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Identity unknown (%s)\n", identity);
837 return;
838 }
839 identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
840
841 if (0 >= handle->rest_handle->data_size)
842 {
844 return;
845 }
846
847 term_data[handle->rest_handle->data_size] = '\0';
848 GNUNET_memcpy (term_data,
849 handle->rest_handle->data,
850 handle->rest_handle->data_size);
851 data_json = json_loads (term_data, JSON_DECODE_ANY, &err);
853 GNUNET_JSON_parse (data_json, attrspec, NULL, NULL));
854 json_decref (data_json);
855 if (NULL == attribute)
856 {
858 "Unable to parse attribute from %s\n",
859 term_data);
861 return;
862 }
866 if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&attribute->id))
867 GNUNET_RECLAIM_id_generate (&attribute->id);
870 identity_priv,
871 attribute,
872 &exp,
874 handle);
875 GNUNET_JSON_parse_free (attrspec);
876}
877
878
889 const char *claim)
890{
891 char *jwt_string;
892 struct GNUNET_RECLAIM_Attribute *attr;
893 char delim[] = ".";
894 const char *type_str = NULL;
895 const char *val_str = NULL;
896 char *data;
897 size_t data_size;
898 uint32_t type;
899 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Parsing JWT attributes.\n");
900 char *decoded_jwt;
901 json_t *json_val;
902 json_error_t *json_err = NULL;
903
905 cred->data,
906 cred->data_size);
907 char *jwt_body = strtok (jwt_string, delim);
908 jwt_body = strtok (NULL, delim);
909 GNUNET_STRINGS_base64_decode (jwt_body, strlen (jwt_body),
910 (void **) &decoded_jwt);
911 json_val = json_loads (decoded_jwt, JSON_DECODE_ANY, json_err);
912 const char *key;
913 json_t *value;
914 json_object_foreach (json_val, key, value) {
915 if (0 == strcasecmp (key,claim))
916 {
917 val_str = json_dumps (value, JSON_ENCODE_ANY);
918 }
919 }
920 type_str = "String";
923 (void **) &data
924 ,
925 &data_size))
926 {
928 "Attribute value from JWT Parser invalid!\n");
930 "Error: Referenced Claim Name not Found",
931 (void **) &data,
932 &data_size);
933 attr = GNUNET_RECLAIM_attribute_new (claim, &cred->id,
935 attr->id = cred->id;
936 attr->flag = 1;
937 }
938 else
939 {
940 attr = GNUNET_RECLAIM_attribute_new (claim, &cred->id,
942 attr->id = cred->id;
943 attr->flag = 1;
944 }
945 return attr;
946}
947
948
953static void
954attr_collect (void *cls,
955 const struct GNUNET_CRYPTO_PublicKey *identity,
956 const struct GNUNET_RECLAIM_Attribute *attr)
957{
958 struct RequestHandle *handle = cls;
959 json_t *attr_obj;
960 const char *type;
961 char *id_str;
962
963 char *tmp_value;
965 attr->data,
966 attr->data_size);
967 attr_obj = json_object ();
968 json_object_set_new (attr_obj, "value", json_string (tmp_value));
969 json_object_set_new (attr_obj, "name", json_string (attr->name));
970
972 json_object_set_new (attr_obj, "flag", json_string ("0"));
973 else
974 json_object_set_new (attr_obj, "flag", json_string ("1"));
976 json_object_set_new (attr_obj, "type", json_string (type));
978 sizeof(attr->id));
979 json_object_set_new (attr_obj, "id", json_string (id_str));
980 GNUNET_free (id_str);
982 sizeof(attr->credential));
983 json_object_set_new (attr_obj, "credential", json_string (id_str));
984 GNUNET_free (id_str);
985 json_array_append (handle->resp_object, attr_obj);
986 json_decref (attr_obj);
987 GNUNET_free (tmp_value);
989}
990
991
999static void
1001 const char *url,
1002 void *cls)
1003{
1004 const struct GNUNET_CRYPTO_PrivateKey *priv_key;
1005 struct RequestHandle *handle = cls;
1006 struct EgoEntry *ego_entry;
1007 char *identity;
1008
1010 "Getting attributes for %s.\n",
1011 handle->url);
1012 if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) >= strlen (handle->url))
1013 {
1014 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
1016 return;
1017 }
1019
1020 for (ego_entry = ego_head; NULL != ego_entry;
1021 ego_entry = ego_entry->next)
1022 if (0 == strcmp (identity, ego_entry->identifier))
1023 break;
1024 handle->resp_object = json_array ();
1025
1026
1027 if (NULL == ego_entry)
1028 {
1029 // Done
1030 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
1032 return;
1033 }
1034 priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
1036 priv_key,
1038 handle,
1039 &attr_collect,
1040 handle,
1042 handle);
1043}
1044
1045
1053static void
1055 const char *url,
1056 void *cls)
1057{
1058 const struct GNUNET_CRYPTO_PrivateKey *priv_key;
1059 struct RequestHandle *handle = cls;
1060 struct GNUNET_RECLAIM_Attribute attr;
1061 struct EgoEntry *ego_entry;
1062 char *identity_id_str;
1063 char *identity;
1064 char *id;
1065
1066 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting attributes.\n");
1067 if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) >= strlen (handle->url))
1068 {
1069 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
1071 return;
1072 }
1073 identity_id_str =
1074 strdup (handle->url + strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) + 1);
1075 identity = strtok (identity_id_str, "/");
1076 id = strtok (NULL, "/");
1077 if ((NULL == identity) || (NULL == id))
1078 {
1079 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Malformed request.\n");
1080 GNUNET_free (identity_id_str);
1082 return;
1083 }
1084
1085 for (ego_entry = ego_head; NULL != ego_entry;
1086 ego_entry = ego_entry->next)
1087 if (0 == strcmp (identity, ego_entry->identifier))
1088 break;
1089 handle->resp_object = json_array ();
1090 if (NULL == ego_entry)
1091 {
1092 // Done
1093 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
1094 GNUNET_free (identity_id_str);
1096 return;
1097 }
1098 priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
1099 memset (&attr, 0, sizeof(struct GNUNET_RECLAIM_Attribute));
1100 GNUNET_STRINGS_string_to_data (id, strlen (id), &attr.id, sizeof(attr.id));
1101 attr.name = "";
1103 priv_key,
1104 &attr,
1106 handle);
1107 GNUNET_free (identity_id_str);
1108}
1109
1110
1111static void
1113 const char *url,
1114 void *cls)
1115{
1116 const struct GNUNET_CRYPTO_PrivateKey *identity_priv;
1117 struct RequestHandle *handle = cls;
1118 struct EgoEntry *ego_entry;
1119 struct GNUNET_RECLAIM_Ticket *ticket = NULL;
1120 struct GNUNET_CRYPTO_PublicKey iss;
1121 struct GNUNET_CRYPTO_PublicKey tmp_pk;
1122 char term_data[handle->rest_handle->data_size + 1];
1123 json_t *data_json;
1124 json_error_t err;
1125 struct GNUNET_JSON_Specification tktspec[] =
1127
1128 if (0 >= handle->rest_handle->data_size)
1129 {
1131 return;
1132 }
1133
1134 term_data[handle->rest_handle->data_size] = '\0';
1135 GNUNET_memcpy (term_data,
1136 handle->rest_handle->data,
1137 handle->rest_handle->data_size);
1138 data_json = json_loads (term_data, JSON_DECODE_ANY, &err);
1139 if ((NULL == data_json) ||
1140 (GNUNET_OK != GNUNET_JSON_parse (data_json, tktspec, NULL, NULL)))
1141 {
1142 handle->emsg = GNUNET_strdup ("Not a ticket!\n");
1144 GNUNET_JSON_parse_free (tktspec);
1145 if (NULL != data_json)
1146 json_decref (data_json);
1147 return;
1148 }
1149 json_decref (data_json);
1150 if (NULL == ticket)
1151 {
1153 "Unable to parse ticket from %s\n",
1154 term_data);
1156 return;
1157 }
1158
1160
1161 for (ego_entry = ego_head; NULL != ego_entry;
1162 ego_entry = ego_entry->next)
1163 {
1164 GNUNET_IDENTITY_ego_get_public_key (ego_entry->ego, &tmp_pk);
1165 if (0 == memcmp (&iss,
1166 &tmp_pk,
1167 sizeof(struct GNUNET_CRYPTO_PublicKey)))
1168 break;
1169 }
1170 if (NULL == ego_entry)
1171 {
1172 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Identity unknown\n");
1173 GNUNET_JSON_parse_free (tktspec);
1174 return;
1175 }
1176 identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
1177
1179 identity_priv,
1180 ticket,
1182 handle);
1183 GNUNET_JSON_parse_free (tktspec);
1184}
1185
1186
1187static void
1189 const struct GNUNET_CRYPTO_PublicKey *identity,
1190 const struct GNUNET_RECLAIM_Attribute *attr,
1191 const struct GNUNET_RECLAIM_Presentation *presentation)
1192{
1193 struct RequestHandle *handle = cls;
1194 char *val_str;
1195 json_t *value;
1196
1197 if (NULL == identity)
1198 {
1200 return;
1201 }
1202
1203 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute: %s\n", attr->name);
1205 attr->data,
1206 attr->data_size);
1207 if (NULL == val_str)
1208 {
1210 "Failed to parse value for: %s\n",
1211 attr->name);
1212 return;
1213 }
1214 value = json_string (val_str);
1215 json_object_set_new (handle->resp_object, attr->name, value);
1216 json_decref (value);
1217 GNUNET_free (val_str);
1218}
1219
1220
1221static void
1223 const char *url,
1224 void *cls)
1225{
1226 struct RequestHandle *handle = cls;
1228 char term_data[handle->rest_handle->data_size + 1];
1229 const char *rp_uri;
1230 json_t *data_json;
1231 json_error_t err;
1232 struct GNUNET_JSON_Specification tktspec[] =
1234 GNUNET_JSON_spec_string ("rp_uri", &rp_uri),
1236
1237 if (0 >= handle->rest_handle->data_size)
1238 {
1240 return;
1241 }
1242
1243 term_data[handle->rest_handle->data_size] = '\0';
1244 GNUNET_memcpy (term_data,
1245 handle->rest_handle->data,
1246 handle->rest_handle->data_size);
1247 data_json = json_loads (term_data, JSON_DECODE_ANY, &err);
1248 if (NULL == data_json)
1249 {
1251 "Unable to parse JSON Object from %s\n",
1252 term_data);
1254 return;
1255 }
1256 if (GNUNET_OK != GNUNET_JSON_parse (data_json, tktspec, NULL, NULL))
1257 {
1258 handle->emsg = GNUNET_strdup ("Not a ticket!\n");
1260 GNUNET_JSON_parse_free (tktspec);
1261 json_decref (data_json);
1262 return;
1263 }
1264 handle->resp_object = json_object ();
1266 ticket,
1267 rp_uri,
1268 &consume_cont,
1269 handle);
1270 GNUNET_JSON_parse_free (tktspec);
1271}
1272
1273
1281static void
1283 const char *url,
1284 void *cls)
1285{
1286 struct MHD_Response *resp;
1287 struct RequestHandle *handle = cls;
1288
1289 // For now, independent of path return all options
1290 resp = GNUNET_REST_create_response (NULL);
1291 GNUNET_assert (MHD_NO != MHD_add_response_header (resp,
1292 "Access-Control-Allow-Methods",
1293 allow_methods));
1294 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
1296 return;
1297}
1298
1299
1332static void
1333list_ego (void *cls,
1334 struct GNUNET_IDENTITY_Ego *ego,
1335 void **ctx,
1336 const char *identifier)
1337{
1338 struct EgoEntry *ego_entry;
1340
1341 if (NULL == ego)
1342 {
1344 return;
1345 }
1347 {
1348 ego_entry = GNUNET_new (struct EgoEntry);
1351 ego_entry->ego = ego;
1352 ego_entry->identifier = GNUNET_strdup (identifier);
1354 ego_tail,
1355 ego_entry);
1356 }
1357 /* Ego renamed or added */
1358 if (identifier != NULL)
1359 {
1360 for (ego_entry = ego_head; NULL != ego_entry;
1361 ego_entry = ego_entry->next)
1362 {
1363 if (ego_entry->ego == ego)
1364 {
1365 /* Rename */
1366 GNUNET_free (ego_entry->identifier);
1367 ego_entry->identifier = GNUNET_strdup (identifier);
1368 break;
1369 }
1370 }
1371 if (NULL == ego_entry)
1372 {
1373 /* Add */
1374 ego_entry = GNUNET_new (struct EgoEntry);
1377 ego_entry->ego = ego;
1378 ego_entry->identifier = GNUNET_strdup (identifier);
1380 ego_tail,
1381 ego_entry);
1382 }
1383 }
1384 else
1385 {
1386 /* Delete */
1387 for (ego_entry = ego_head; NULL != ego_entry;
1388 ego_entry = ego_entry->next)
1389 {
1390 if (ego_entry->ego == ego)
1391 break;
1392 }
1393 if (NULL == ego_entry)
1394 return; /* Not found */
1395
1397 ego_tail,
1398 ego_entry);
1399 GNUNET_free (ego_entry->identifier);
1400 GNUNET_free (ego_entry->keystring);
1401 GNUNET_free (ego_entry);
1402 return;
1403 }
1404
1405}
1406
1407
1410 struct GNUNET_REST_RequestHandle *rest_handle,
1412 void *proc_cls)
1413{
1414 struct RequestHandle *handle = GNUNET_new (struct RequestHandle);
1416 static const struct GNUNET_REST_RequestHandler handlers[] =
1417 { { MHD_HTTP_METHOD_GET,
1419 { MHD_HTTP_METHOD_POST,
1421 { MHD_HTTP_METHOD_DELETE,
1423 { MHD_HTTP_METHOD_GET,
1425 { MHD_HTTP_METHOD_POST,
1427 { MHD_HTTP_METHOD_DELETE,
1429 { MHD_HTTP_METHOD_GET,
1431 { MHD_HTTP_METHOD_POST,
1433 { MHD_HTTP_METHOD_POST,
1435 { MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_RECLAIM, &options_cont },
1437
1438 handle->response_code = 0;
1440 handle->proc_cls = proc_cls;
1441 handle->proc = proc;
1442 handle->rest_handle = rest_handle;
1443
1444 handle->url = GNUNET_strdup (rest_handle->url);
1445 if (handle->url[strlen (handle->url) - 1] == '/')
1446 handle->url[strlen (handle->url) - 1] = '\0';
1447 handle->timeout_task =
1451 handle);
1452 if (GNUNET_NO ==
1453 GNUNET_REST_handle_request (handle->rest_handle, handlers, &err, handle))
1454 {
1456 return GNUNET_NO;
1457 }
1458
1459 return GNUNET_YES;
1460}
1461
1462
1469void *
1471{
1472 static struct Plugin plugin;
1473 struct GNUNET_REST_Plugin *api;
1474
1475 rcfg = c;
1476 if (NULL != plugin.cfg)
1477 return NULL; /* can only initialize once! */
1478 memset (&plugin, 0, sizeof(struct Plugin));
1479 plugin.cfg = rcfg;
1480 api = GNUNET_new (struct GNUNET_REST_Plugin);
1481 api->cls = &plugin;
1484 "%s, %s, %s, %s, %s",
1485 MHD_HTTP_METHOD_GET,
1486 MHD_HTTP_METHOD_POST,
1487 MHD_HTTP_METHOD_PUT,
1488 MHD_HTTP_METHOD_DELETE,
1489 MHD_HTTP_METHOD_OPTIONS);
1494 _ ("Identity Provider REST API initialized\n"));
1495 return api;
1496}
1497
1498
1505void *
1507{
1508 struct Plugin *plugin = api->cls;
1509 struct RequestHandle *request;
1510 struct EgoEntry *ego_entry;
1511 struct EgoEntry *ego_tmp;
1512
1513 plugin->cfg = NULL;
1514 while (NULL != (request = requests_head))
1515 do_error (request);
1516 if (NULL != idp)
1518 if (NULL != identity_handle)
1520 for (ego_entry = ego_head; NULL != ego_entry;)
1521 {
1522 ego_tmp = ego_entry;
1523 ego_entry = ego_entry->next;
1524 GNUNET_free (ego_tmp->identifier);
1525 GNUNET_free (ego_tmp->keystring);
1526 GNUNET_free (ego_tmp);
1527 }
1528
1530 GNUNET_free (api);
1532 "Identity Provider REST plugin is finished\n");
1533 return NULL;
1534}
1535
1536
1537/* end of plugin_rest_reclaim.c */
struct GNUNET_MQ_MessageHandlers handlers[]
Definition: 003.c:1
static struct GNUNET_TESTING_PluginFunctions * plugin
Plugin to dynamically load a test case.
static char * data
The data to insert into the dht.
struct GNUNET_HashCode key
The key used in the DHT.
static struct GNUNET_FS_Handle * ctx
struct GNUNET_CRYPTO_PrivateKey pk
Private key from command line option, or NULL.
static struct GNUNET_IDENTITY_Handle * id
Handle to IDENTITY.
static char * value
Value of the record to add/remove.
static uint32_t type
Type string converted to DNS type value.
static size_t data_size
Number of bytes in data.
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
struct GNUNET_RECLAIM_Attribute * claim
Claim to store.
static struct GNUNET_RECLAIM_Ticket ticket
Ticket to consume.
static char * type_str
Attribute type.
static struct GNUNET_VPN_RedirectionRequest * request
Opaque redirection request handle.
Definition: gnunet-vpn.c:40
static struct GNUNET_VPN_Handle * handle
Handle to vpn service.
Definition: gnunet-vpn.c:35
API to the GNS service.
API that can be used to manipulate GNS record data.
Identity service; implements identity management for GNUnet.
functions to parse JSON objects into GNUnet objects
void GNUNET_JSON_parse_free(struct GNUNET_JSON_Specification *spec)
Frees all elements allocated during a GNUNET_JSON_parse() operation.
Definition: json.c:94
struct GNUNET_JSON_Specification GNUNET_JSON_spec_string(const char *name, const char **strptr)
The expected field stores a string.
Definition: json_helper.c:306
enum GNUNET_GenericReturnValue GNUNET_JSON_parse(const json_t *root, struct GNUNET_JSON_Specification *spec, const char **error_json_name, unsigned int *error_line)
Navigate and parse data in a JSON tree.
Definition: json.c:32
struct GNUNET_JSON_Specification GNUNET_JSON_spec_end(void)
End of a parser specification.
Definition: json_helper.c:33
Identity attribute definitions.
reclaim service; implements identity and personal data sharing for GNUnet
API for helper library to parse/create REST.
GNUnet service REST plugin header.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
enum GNUNET_GenericReturnValue GNUNET_GNS_parse_ztld(const char *name, struct GNUNET_CRYPTO_PublicKey *ztld_key)
Try to parse the zTLD into a public key.
Definition: gns_tld_api.c:228
const struct GNUNET_CRYPTO_PrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:517
struct GNUNET_IDENTITY_Handle * GNUNET_IDENTITY_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_IDENTITY_Callback cb, void *cb_cls)
Connect to the identity service.
Definition: identity_api.c:487
void GNUNET_IDENTITY_disconnect(struct GNUNET_IDENTITY_Handle *h)
Disconnect from identity service.
Definition: identity_api.c:732
void GNUNET_IDENTITY_ego_get_public_key(struct GNUNET_IDENTITY_Ego *ego, struct GNUNET_CRYPTO_PublicKey *pk)
Get the identifier (public key) of an ego.
Definition: identity_api.c:529
#define GNUNET_log(kind,...)
char * GNUNET_CRYPTO_public_key_to_string(const struct GNUNET_CRYPTO_PublicKey *key)
Creates a (Base32) string representation of the public key.
Definition: crypto_pkey.c:394
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
GNUNET_GenericReturnValue
Named constants for return values.
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_SYSERR
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
int GNUNET_RECLAIM_attribute_string_to_value(uint32_t type, const char *s, void **data, size_t *data_size)
Convert human-readable version of a 'claim' of an attribute to the binary representation.
void GNUNET_RECLAIM_attribute_list_destroy(struct GNUNET_RECLAIM_AttributeList *attrs)
Destroy claim list.
char * GNUNET_RECLAIM_credential_get_issuer(const struct GNUNET_RECLAIM_Credential *cred)
char * GNUNET_RECLAIM_credential_value_to_string(uint32_t type, const void *data, size_t data_size)
Convert the 'claim' of an credential to a string.
#define GNUNET_RECLAIM_id_is_zero(a)
const char * GNUNET_RECLAIM_credential_number_to_typename(uint32_t type)
Convert an credential type number to the corresponding credential type string.
struct GNUNET_RECLAIM_AttributeList * GNUNET_RECLAIM_credential_get_attributes(const struct GNUNET_RECLAIM_Credential *cred)
Convert an credential type name to the corresponding number.
#define GNUNET_RECLAIM_id_generate(id)
int GNUNET_RECLAIM_credential_get_expiration(const struct GNUNET_RECLAIM_Credential *cred, struct GNUNET_TIME_Absolute *exp)
char * GNUNET_RECLAIM_attribute_value_to_string(uint32_t type, const void *data, size_t data_size)
Convert the 'claim' of an attribute to a string.
struct GNUNET_RECLAIM_Attribute * GNUNET_RECLAIM_attribute_new(const char *attr_name, const struct GNUNET_RECLAIM_Identifier *credential, uint32_t type, const void *data, size_t data_size)
Create a new attribute claim.
const char * GNUNET_RECLAIM_attribute_number_to_typename(uint32_t type)
Convert a type number to the corresponding type string.
uint32_t GNUNET_RECLAIM_attribute_typename_to_number(const char *typename)
Convert a type name to the corresponding number.
void GNUNET_RECLAIM_disconnect(struct GNUNET_RECLAIM_Handle *h)
Disconnect from identity provider service.
Definition: reclaim_api.c:1150
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_credential_store(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_PrivateKey *pkey, const struct GNUNET_RECLAIM_Credential *credential, const struct GNUNET_TIME_Relative *exp_interval, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
Store a credential.
Definition: reclaim_api.c:1254
void GNUNET_RECLAIM_ticket_iteration_next(struct GNUNET_RECLAIM_TicketIterator *it)
Calls the ticket processor specified in GNUNET_RECLAIM_ticket_iteration_start for the next record.
Definition: reclaim_api.c:1639
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_ticket_consume(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_RECLAIM_Ticket *ticket, const char *rp_uri, GNUNET_RECLAIM_AttributeTicketResult cb, void *cb_cls)
Consumes an issued ticket.
Definition: reclaim_api.c:1546
void GNUNET_RECLAIM_get_attributes_stop(struct GNUNET_RECLAIM_AttributeIterator *it)
Stops iteration and releases the handle for further calls.
Definition: reclaim_api.c:1398
void GNUNET_RECLAIM_get_credentials_next(struct GNUNET_RECLAIM_CredentialIterator *ait)
Calls the record processor specified in GNUNET_RECLAIM_get_credentials_start for the next record.
Definition: reclaim_api.c:1462
struct GNUNET_RECLAIM_AttributeIterator * GNUNET_RECLAIM_get_attributes_start(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_PrivateKey *identity, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_RECLAIM_AttributeResult proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
List all attributes for a local identity.
Definition: reclaim_api.c:1339
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_ticket_revoke(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_PrivateKey *identity, const struct GNUNET_RECLAIM_Ticket *ticket, GNUNET_RECLAIM_ContinuationWithStatus cb, void *cb_cls)
Revoked an issued ticket.
Definition: reclaim_api.c:1690
void GNUNET_RECLAIM_get_attributes_next(struct GNUNET_RECLAIM_AttributeIterator *it)
Calls the record processor specified in GNUNET_RECLAIM_get_attributes_start for the next record.
Definition: reclaim_api.c:1384
struct GNUNET_RECLAIM_Handle * GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the re:claimID service.
Definition: reclaim_api.c:1118
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_attribute_store(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_PrivateKey *pkey, const struct GNUNET_RECLAIM_Attribute *attr, const struct GNUNET_TIME_Relative *exp_interval, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
Store an attribute.
Definition: reclaim_api.c:1169
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_attribute_delete(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_PrivateKey *pkey, const struct GNUNET_RECLAIM_Attribute *attr, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
Delete an attribute.
Definition: reclaim_api.c:1213
struct GNUNET_RECLAIM_TicketIterator * GNUNET_RECLAIM_ticket_iteration_start(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_PrivateKey *identity, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_RECLAIM_TicketCallback proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
Lists all tickets that have been issued to remote identities (relying parties)
Definition: reclaim_api.c:1586
void GNUNET_RECLAIM_get_credentials_stop(struct GNUNET_RECLAIM_CredentialIterator *ait)
Stops iteration and releases the handle for further calls.
Definition: reclaim_api.c:1477
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_credential_delete(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_PrivateKey *pkey, const struct GNUNET_RECLAIM_Credential *cred, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
Delete a credential.
Definition: reclaim_api.c:1298
void GNUNET_RECLAIM_ticket_iteration_stop(struct GNUNET_RECLAIM_TicketIterator *it)
Stops iteration and releases the handle for further calls.
Definition: reclaim_api.c:1659
struct GNUNET_RECLAIM_CredentialIterator * GNUNET_RECLAIM_get_credentials_start(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_PrivateKey *identity, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_RECLAIM_CredentialResult proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
List all credentials for a local identity.
Definition: reclaim_api.c:1416
int GNUNET_REST_handle_request(struct GNUNET_REST_RequestHandle *conn, const struct GNUNET_REST_RequestHandler *handlers, struct GNUNET_REST_RequestHandlerError *err, void *cls)
Definition: rest.c:64
void(* GNUNET_REST_ResultProcessor)(void *cls, struct MHD_Response *resp, int status)
Iterator called on obtained result for a REST result.
#define GNUNET_REST_HANDLER_END
struct MHD_Response * GNUNET_REST_create_response(const char *data)
Create REST MHD response.
Definition: rest.c:44
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:981
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1305
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1278
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:764
enum GNUNET_GenericReturnValue GNUNET_STRINGS_string_to_data(const char *enc, size_t enclen, void *out, size_t out_size)
Convert CrockfordBase32 encoding back to data.
Definition: strings.c:789
size_t GNUNET_STRINGS_base64_decode(const char *data, size_t len, void **output)
Decode from Base64.
Definition: strings.c:1724
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
#define GNUNET_TIME_UNIT_HOURS
One hour.
@ MHD_HTTP_BAD_REQUEST
Bad Request [RFC7231, Section 6.5.1].
@ MHD_HTTP_OK
OK [RFC7231, Section 6.3.1].
struct GNUNET_JSON_Specification GNUNET_RECLAIM_JSON_spec_credential(struct GNUNET_RECLAIM_Credential **cred)
JSON Specification for credential claims.
Definition: json_reclaim.c:354
struct GNUNET_JSON_Specification GNUNET_RECLAIM_JSON_spec_attribute(struct GNUNET_RECLAIM_Attribute **attr)
JSON Specification for Reclaim claims.
Definition: json_reclaim.c:146
struct GNUNET_JSON_Specification GNUNET_RECLAIM_JSON_spec_ticket(struct GNUNET_RECLAIM_Ticket **ticket)
JSON Specification for Reclaim tickets.
Definition: json_reclaim.c:230
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
static struct EgoEntry * ego_tail
Ego list.
#define GNUNET_REST_API_NS_IDENTITY_REVOKE
Revoke namespace.
static struct GNUNET_RECLAIM_Handle * idp
Identity Provider.
static void finished_cont(void *cls, int32_t success, const char *emsg)
#define GNUNET_REST_API_NS_RECLAIM_CREDENTIAL
Credential namespace.
struct GNUNET_RECLAIM_Attribute * parse_jwt(const struct GNUNET_RECLAIM_Credential *cred, const char *claim)
Parse a JWT and return the respective claim value as Attribute.
void * REST_reclaim_done(struct GNUNET_REST_Plugin *api)
Exit point from the plugin.
static void delete_finished_cb(void *cls, int32_t success, const char *emsg)
static void do_timeout(void *cls)
Task run on timeout, sends error message.
#define GNUNET_REST_API_NS_IDENTITY_TICKETS
Ticket namespace.
#define GNUNET_REST_API_NS_IDENTITY_CONSUME
Revoke namespace.
static void return_response(void *cls)
Return attributes for identity.
#define GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES
Attribute namespace.
static void delete_credential_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
Deletes credential from an identity.
static void revoke_ticket_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
static void consume_cont(void *cls, const struct GNUNET_CRYPTO_PublicKey *identity, const struct GNUNET_RECLAIM_Attribute *attr, const struct GNUNET_RECLAIM_Presentation *presentation)
#define GNUNET_REST_API_NS_RECLAIM
REST root namespace.
static void delete_attribute_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
List attributes for identity request.
void * REST_reclaim_init(struct GNUNET_CONFIGURATION_Handle *c)
Entry point for the plugin.
static void collect_error_cb(void *cls)
static void list_tickets_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
List tickets for identity request.
#define ID_REST_STATE_INIT
State while collecting all egos.
static struct RequestHandle * requests_head
DLL.
static void options_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
Respond to OPTIONS request.
static int state
The processing state.
static struct EgoEntry * ego_head
Ego list.
static void cred_collect(void *cls, const struct GNUNET_CRYPTO_PublicKey *identity, const struct GNUNET_RECLAIM_Credential *cred)
Collect all credentials for an ego.
static void list_ego(void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, const char *identifier)
If listing is enabled, prints information about the egos.
static void list_credential_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
Lists credential for identity request.
enum GNUNET_GenericReturnValue REST_reclaim_process_request(void *plugin, struct GNUNET_REST_RequestHandle *rest_handle, GNUNET_REST_ResultProcessor proc, void *proc_cls)
Function processing the REST call.
static void add_credential_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
static char * allow_methods
HTTP methods allows for this plugin.
static void collect_finished_cb(void *cls)
static void attr_collect(void *cls, const struct GNUNET_CRYPTO_PublicKey *identity, const struct GNUNET_RECLAIM_Attribute *attr)
Collect all attributes for an ego.
static struct RequestHandle * requests_tail
DLL.
static struct GNUNET_IDENTITY_Handle * identity_handle
Handle to Identity service.
static void add_attribute_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
static void list_attribute_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
List attributes for identity request.
static void consume_ticket_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
const struct GNUNET_CONFIGURATION_Handle * rcfg
The configuration handle.
#define ID_REST_STATE_POST_INIT
Done collecting egos.
static void ticket_collect(void *cls, const struct GNUNET_RECLAIM_Ticket *ticket, const char *rp_uri)
Collect all attributes for an ego.
static void do_error(void *cls)
Task run on error, sends error message.
static void cleanup_handle(void *cls)
Cleanup lookup handle.
The default namestore ego.
char * identifier
Ego Identifier.
struct EgoEntry * prev
DLL.
char * keystring
Public key string.
struct EgoEntry * next
DLL.
struct GNUNET_IDENTITY_Ego * ego
The Ego.
void * cls
Closure for all of the callbacks.
A private key for an identity as per LSD0001.
An identity key as per LSD0001.
Handle for an ego.
Definition: identity.h:37
Handle for the service.
Definition: identity_api.c:97
Handle for an operation with the identity service.
Definition: identity_api.c:41
Entry in parser specification for GNUNET_JSON_parse().
void * cls
Closure for parser and cleaner.
Handle for a attribute iterator operation.
Definition: reclaim_api.c:181
struct GNUNET_RECLAIM_Attribute * attribute
The attribute claim.
struct GNUNET_RECLAIM_AttributeListEntry * next
DLL.
A list of GNUNET_RECLAIM_Attribute structures.
struct GNUNET_RECLAIM_AttributeListEntry * list_head
List head.
const char * name
The name of the attribute.
struct GNUNET_RECLAIM_Identifier credential
Referenced ID of credential (may be GNUNET_RECLAIM_ID_ZERO if self-creded)
struct GNUNET_RECLAIM_Identifier id
ID.
uint32_t type
Type of Claim.
const void * data
Binary value stored as attribute value.
size_t data_size
Number of bytes in data.
Handle for a credential iterator operation.
Definition: reclaim_api.c:248
uint32_t type
Type/Format of Claim.
const char * name
The name of the credential.
const void * data
Binary value stored as credential value.
size_t data_size
Number of bytes in data.
struct GNUNET_RECLAIM_Identifier id
ID.
Handle to the service.
Definition: reclaim_api.c:316
Handle for an operation with the service.
Definition: reclaim_api.c:40
A credential presentation.
Handle for a ticket iterator operation.
Definition: reclaim_api.c:118
The authorization ticket.
char gns_name[63 *2+2]
The ticket.
struct returned by the initialization function of the plugin
char * name
Plugin name.
void * cls
The closure of the plugin.
const char * url
The url as string.
void(* proc)(struct GNUNET_REST_RequestHandle *handle, const char *url, void *cls)
Namespace to handle.
Entry in list of pending tasks.
Definition: scheduler.c:136
Time for absolute times used by GNUnet, in microseconds.
uint64_t abs_value_us
The actual value.
Time for relative time used by GNUnet, in microseconds.
Handle for a plugin.
Definition: block.c:38
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
The request handle.
Definition: config_plugin.c:46
struct GNUNET_RECLAIM_TicketIterator * ticket_it
Ticket iterator.
struct GNUNET_RECLAIM_Ticket ticket
A ticket.
char * emsg
Error response message.
Definition: gns_plugin.c:142
struct GNUNET_IDENTITY_Operation * op
IDENTITY Operation.
struct RequestHandle * prev
DLL.
Definition: config_plugin.c:55
struct GNUNET_RECLAIM_AttributeList * attr_list
Attribute claim list.
struct GNUNET_RECLAIM_Operation * idp_op
Idp Operation.
int response_code
HTTP response code.
Definition: config_plugin.c:75
struct EgoEntry * ego_entry
IDENTITY Operation.
struct GNUNET_SCHEDULER_Task * timeout_task
ID of a task associated with the resolution process.
Definition: gns_plugin.c:122
struct GNUNET_CRYPTO_PrivateKey priv_key
Pointer to ego private key.
void * proc_cls
The closure of the result processor.
Definition: config_plugin.c:70
struct GNUNET_RECLAIM_AttributeIterator * attr_it
Attribute iterator.
GNUNET_REST_ResultProcessor proc
The plugin result processor.
Definition: config_plugin.c:65
struct RequestHandle * next
DLL.
Definition: config_plugin.c:50
struct GNUNET_RECLAIM_CredentialIterator * cred_it
Credential iterator.
json_t * resp_object
Response object.
struct GNUNET_REST_RequestHandle * rest_handle
Handle to rest request.
Definition: config_plugin.c:60
char * url
The URL.
Definition: config_plugin.c:80
struct GNUNET_TIME_Relative timeout
Desired timeout for the lookup (default is no timeout).
Definition: gns_plugin.c:117