GNUnet 0.22.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"
41#include "reclaim_plugin.h"
42
46#define GNUNET_REST_API_NS_RECLAIM "/reclaim"
47
51#define GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES "/reclaim/attributes"
52
56#define GNUNET_REST_API_NS_RECLAIM_CREDENTIAL "/reclaim/credential"
57
61#define GNUNET_REST_API_NS_IDENTITY_TICKETS "/reclaim/tickets"
62
66#define GNUNET_REST_API_NS_IDENTITY_REVOKE "/reclaim/revoke"
67
71#define GNUNET_REST_API_NS_IDENTITY_CONSUME "/reclaim/consume"
72
76#define ID_REST_STATE_INIT 0
77
81#define ID_REST_STATE_POST_INIT 1
82
87
91static char *allow_methods;
92
96static struct EgoEntry *ego_head;
97
101static struct EgoEntry *ego_tail;
102
106static int state;
107
112
117
121struct Plugin
122{
123 const struct GNUNET_CONFIGURATION_Handle *cfg;
124};
125
129struct EgoEntry
130{
134 struct EgoEntry *next;
135
139 struct EgoEntry *prev;
140
144 char *identifier;
145
149 char *keystring;
150
154 struct GNUNET_IDENTITY_Ego *ego;
155};
156
157
158struct RequestHandle
159{
163 struct RequestHandle *next;
164
168 struct RequestHandle *prev;
169
173 struct EgoEntry *ego_entry;
174
179
184
189
194
199
204
209
214
219
224
229
234
238 void *proc_cls;
239
243 char *url;
244
248 char *emsg;
249
253 int response_code;
254
258 json_t *resp_object;
259};
260
265
270
271
276static void
277cleanup_handle (void *cls)
278{
279 struct RequestHandle *handle = cls;
280
281 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n");
282 if (NULL != handle->resp_object)
283 json_decref (handle->resp_object);
284 if (NULL != handle->timeout_task)
285 GNUNET_SCHEDULER_cancel (handle->timeout_task);
286 if (NULL != handle->attr_it)
288 if (NULL != handle->cred_it)
290 if (NULL != handle->ticket_it)
292 if (NULL != handle->url)
293 GNUNET_free (handle->url);
294 if (NULL != handle->emsg)
295 GNUNET_free (handle->emsg);
296 if (NULL != handle->attr_list)
300 handle);
302}
303
304
310static void
311do_error (void *cls)
312{
313 struct RequestHandle *handle = cls;
314 struct MHD_Response *resp;
315 char *json_error;
316
317 GNUNET_asprintf (&json_error, "{ \"error\" : \"%s\" }", handle->emsg);
318 if (0 == handle->response_code)
319 {
320 handle->response_code = MHD_HTTP_BAD_REQUEST;
321 }
322 resp = GNUNET_REST_create_response (json_error);
323 GNUNET_assert (MHD_NO != MHD_add_response_header (resp, "Content-Type",
324 "application/json"));
325 handle->proc (handle->proc_cls, resp, handle->response_code);
327 GNUNET_free (json_error);
328}
329
330
336static void
337do_timeout (void *cls)
338{
339 struct RequestHandle *handle = cls;
340
341 handle->timeout_task = NULL;
343}
344
345
346static void
348{
350}
351
352
353static void
354finished_cont (void *cls, int32_t success, const char *emsg)
355{
356 struct RequestHandle *handle = cls;
357 struct MHD_Response *resp;
358
359 handle->idp_op = NULL;
360 if (GNUNET_OK != success)
361 {
363 return;
364 }
365 resp = GNUNET_REST_create_response (emsg);
366 GNUNET_assert (MHD_NO != MHD_add_response_header (resp,
367 "Content-Type",
368 "application/json"));
369 GNUNET_assert (MHD_NO != MHD_add_response_header (resp,
370 "Access-Control-Allow-Methods",
372 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
374}
375
376
377static void
378delete_finished_cb (void *cls, int32_t success, const char *emsg)
379{
380 struct RequestHandle *handle = cls;
381 struct MHD_Response *resp;
382
383 if (GNUNET_OK != success)
384 {
386 return;
387 }
388 resp = GNUNET_REST_create_response (emsg);
389 GNUNET_assert (MHD_NO != MHD_add_response_header (resp,
390 "Access-Control-Allow-Methods",
392 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
394}
395
396
402static void
404{
405 char *result_str;
406 struct RequestHandle *handle = cls;
407 struct MHD_Response *resp;
408
409 result_str = json_dumps (handle->resp_object, 0);
410 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str);
411 resp = GNUNET_REST_create_response (result_str);
412 GNUNET_assert (MHD_NO !=
413 MHD_add_response_header (resp,
414 "Access-Control-Allow-Methods",
416 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
417 GNUNET_free (result_str);
419}
420
421
422static void
424{
425 struct RequestHandle *handle = cls;
426
427 // Done
428 handle->attr_it = NULL;
429 handle->cred_it = NULL;
430 handle->ticket_it = NULL;
432}
433
434
439static void
441 const char *rp_uri)
442{
443 json_t *json_resource;
444 struct RequestHandle *handle = cls;
445
446 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding ticket\n");
447 json_resource = json_object ();
448 json_array_append (handle->resp_object, json_resource);
449
450 json_object_set_new (json_resource, "gns_name", json_string (ticket->gns_name)
451 );
452 json_object_set_new (json_resource, "rp_uri", json_string (rp_uri));
454}
455
456
457static void
459 const char *url,
460 void *cls)
461{
462 struct RequestHandle *handle = cls;
463 const struct GNUNET_CRYPTO_PrivateKey *identity_priv;
464 const char *identity;
465 struct EgoEntry *ego_entry;
466 struct GNUNET_RECLAIM_Credential *attribute;
467 struct GNUNET_TIME_Relative exp;
468 char term_data[handle->rest_handle->data_size + 1];
469 json_t *data_json;
470 json_error_t err;
471 struct GNUNET_JSON_Specification attrspec[] =
474
476 "Adding an credential for %s.\n",
477 handle->url);
478 if (strlen (GNUNET_REST_API_NS_RECLAIM_CREDENTIAL) >= strlen (
479 handle->url))
480 {
481 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
483 return;
484 }
485 identity = handle->url + strlen (
487
488 for (ego_entry = ego_head; NULL != ego_entry;
489 ego_entry = ego_entry->next)
490 if (0 == strcmp (identity, ego_entry->identifier))
491 break;
492
493 if (NULL == ego_entry)
494 {
495 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Identity unknown (%s)\n", identity);
496 return;
497 }
498 identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
499
500 if (0 >= handle->rest_handle->data_size)
501 {
503 return;
504 }
505
506 term_data[handle->rest_handle->data_size] = '\0';
507 GNUNET_memcpy (term_data,
508 handle->rest_handle->data,
509 handle->rest_handle->data_size);
510 data_json = json_loads (term_data, JSON_DECODE_ANY, &err);
511 if (GNUNET_OK != GNUNET_JSON_parse (data_json, attrspec, NULL, NULL))
512 {
513 json_decref (data_json);
515 "Unable to parse JSON from %s\n",
516 term_data);
518 return;
519 }
520 json_decref (data_json);
521 if (NULL == attribute)
522 {
524 "Unable to parse credential from %s\n",
525 term_data);
527 return;
528 }
532 if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&attribute->id))
533 GNUNET_RECLAIM_id_generate (&attribute->id);
536 identity_priv,
537 attribute,
538 &exp,
540 handle);
541 GNUNET_JSON_parse_free (attrspec);
542}
543
544
549static void
551 const struct GNUNET_CRYPTO_PublicKey *identity,
552 const struct GNUNET_RECLAIM_Credential *cred)
553{
554 struct RequestHandle *handle = cls;
555 struct GNUNET_RECLAIM_AttributeList *attrs;
557 struct GNUNET_TIME_Absolute exp;
558 json_t *attr_obj;
559 json_t *cred_obj;
560 const char *type;
561 char *tmp_value;
562 char *id_str;
563 char *issuer;
564
565
566 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding credential: %s\n",
567 cred->name);
571 cred->data,
572 cred->data_size);
573 cred_obj = json_object ();
574 json_object_set_new (cred_obj, "value", json_string (tmp_value));
575 json_object_set_new (cred_obj, "name", json_string (cred->name));
577 json_object_set_new (cred_obj, "type", json_string (type));
578 if (NULL != issuer)
579 {
580 json_object_set_new (cred_obj, "issuer", json_string (issuer));
581 GNUNET_free (issuer);
582 }
584 &exp))
585 {
586 json_object_set_new (cred_obj, "expiration", json_integer (
587 exp.abs_value_us));
588 }
590 sizeof(cred->id));
591 json_object_set_new (cred_obj, "id", json_string (id_str));
592 GNUNET_free (tmp_value);
593 GNUNET_free (id_str);
594 if (NULL != attrs)
595 {
596 json_t *attr_arr = json_array ();
597 for (ale = attrs->list_head; NULL != ale; ale = ale->next)
598 {
599 tmp_value =
601 ale->attribute->data,
602 ale->attribute->data_size);
603 attr_obj = json_object ();
604 json_object_set_new (attr_obj, "value", json_string (tmp_value));
605 json_object_set_new (attr_obj, "name", json_string (
606 ale->attribute->name));
607
608 json_object_set_new (attr_obj, "flag", json_string ("1")); // FIXME
610 json_object_set_new (attr_obj, "type", json_string (type));
611 json_object_set_new (attr_obj, "id", json_string (""));
612 json_object_set_new (attr_obj, "credential", json_string (""));
613 json_array_append_new (attr_arr, attr_obj);
614 GNUNET_free (tmp_value);
615 }
616 json_object_set_new (cred_obj, "attributes", attr_arr);
617 }
618 json_array_append_new (handle->resp_object, cred_obj);
619 if (NULL != attrs)
622}
623
624
632static void
634 const char *url,
635 void *cls)
636{
637 struct RequestHandle *handle = cls;
638 const struct GNUNET_CRYPTO_PrivateKey *priv_key;
639 struct EgoEntry *ego_entry;
640 char *identity;
641
643 "Getting credentials for %s.\n",
644 handle->url);
645 if (strlen (GNUNET_REST_API_NS_RECLAIM_CREDENTIAL) >= strlen (
646 handle->url))
647 {
648 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
650 return;
651 }
652 identity = handle->url + strlen (
654
655 for (ego_entry = ego_head; NULL != ego_entry;
656 ego_entry = ego_entry->next)
657 if (0 == strcmp (identity, ego_entry->identifier))
658 break;
659 handle->resp_object = json_array ();
660
661
662 if (NULL == ego_entry)
663 {
664 // Done
665 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
667 return;
668 }
669 priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
671 priv_key,
673 handle,
675 handle,
676 &
678 handle);
679}
680
681
689static void
691 const char *url,
692 void *cls)
693{
694 struct RequestHandle *handle = cls;
695 const struct GNUNET_CRYPTO_PrivateKey *priv_key;
696 struct GNUNET_RECLAIM_Credential attr;
697 struct EgoEntry *ego_entry;
698 char *identity_id_str;
699 char *identity;
700 char *id;
701
702 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting credential.\n");
703 if (strlen (GNUNET_REST_API_NS_RECLAIM_CREDENTIAL) >= strlen (
704 handle->url))
705 {
706 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
708 return;
709 }
710 identity_id_str =
711 strdup (handle->url + strlen (
713 identity = strtok (identity_id_str, "/");
714 id = strtok (NULL, "/");
715 if ((NULL == identity) || (NULL == id))
716 {
717 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Malformed request.\n");
718 GNUNET_free (identity_id_str);
720 return;
721 }
722
723 for (ego_entry = ego_head; NULL != ego_entry;
724 ego_entry = ego_entry->next)
725 if (0 == strcmp (identity, ego_entry->identifier))
726 break;
727 handle->resp_object = json_array ();
728 if (NULL == ego_entry)
729 {
730 // Done
731 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
732 GNUNET_free (identity_id_str);
734 return;
735 }
736 priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
737 memset (&attr, 0, sizeof(struct GNUNET_RECLAIM_Credential));
738 GNUNET_STRINGS_string_to_data (id, strlen (id), &attr.id, sizeof(attr.id));
739 attr.name = "";
741 priv_key,
742 &attr,
744 handle);
745 GNUNET_free (identity_id_str);
746}
747
748
756static void
758 const char *url,
759 void *cls)
760{
761 const struct GNUNET_CRYPTO_PrivateKey *priv_key;
762 struct RequestHandle *handle = cls;
763 struct EgoEntry *ego_entry;
764 char *identity;
765
767 "Getting tickets for %s.\n",
768 handle->url);
769 if (strlen (GNUNET_REST_API_NS_IDENTITY_TICKETS) >= strlen (handle->url))
770 {
771 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
773 return;
774 }
776
777 for (ego_entry = ego_head; NULL != ego_entry;
778 ego_entry = ego_entry->next)
779 if (0 == strcmp (identity, ego_entry->identifier))
780 break;
781 handle->resp_object = json_array ();
782
783 if (NULL == ego_entry)
784 {
785 // Done
786 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
788 return;
789 }
790 priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
791 handle->ticket_it =
793 priv_key,
795 handle,
797 handle,
799 handle);
800}
801
802
803static void
805 const char *url,
806 void *cls)
807{
808 const struct GNUNET_CRYPTO_PrivateKey *identity_priv;
809 const char *identity;
810 struct RequestHandle *handle = cls;
811 struct EgoEntry *ego_entry;
812 struct GNUNET_RECLAIM_Attribute *attribute;
813 struct GNUNET_TIME_Relative exp;
814 char term_data[handle->rest_handle->data_size + 1];
815 json_t *data_json;
816 json_error_t err;
817 struct GNUNET_JSON_Specification attrspec[] =
819
821 "Adding an attribute for %s.\n",
822 handle->url);
823 if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) >= strlen (handle->url))
824 {
825 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
827 return;
828 }
830
831 for (ego_entry = ego_head; NULL != ego_entry;
832 ego_entry = ego_entry->next)
833 if (0 == strcmp (identity, ego_entry->identifier))
834 break;
835
836 if (NULL == ego_entry)
837 {
838 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Identity unknown (%s)\n", identity);
839 return;
840 }
841 identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
842
843 if (0 >= handle->rest_handle->data_size)
844 {
846 return;
847 }
848
849 term_data[handle->rest_handle->data_size] = '\0';
850 GNUNET_memcpy (term_data,
851 handle->rest_handle->data,
852 handle->rest_handle->data_size);
853 data_json = json_loads (term_data, JSON_DECODE_ANY, &err);
855 GNUNET_JSON_parse (data_json, attrspec, NULL, NULL));
856 json_decref (data_json);
857 if (NULL == attribute)
858 {
860 "Unable to parse attribute from %s\n",
861 term_data);
863 return;
864 }
868 if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&attribute->id))
869 GNUNET_RECLAIM_id_generate (&attribute->id);
872 identity_priv,
873 attribute,
874 &exp,
876 handle);
877 GNUNET_JSON_parse_free (attrspec);
878}
879
880
889//static struct GNUNET_RECLAIM_Attribute *
890//parse_jwt (const struct GNUNET_RECLAIM_Credential *cred,
891// const char *claim)
892//{
893// char *jwt_string;
894// struct GNUNET_RECLAIM_Attribute *attr;
895// char delim[] = ".";
896// const char *type_str = NULL;
897// const char *val_str = NULL;
898// char *data;
899// size_t data_size;
900// uint32_t type;
901// GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Parsing JWT attributes.\n");
902// char *decoded_jwt;
903// json_t *json_val;
904// json_error_t *json_err = NULL;
905//
906// jwt_string = GNUNET_RECLAIM_credential_value_to_string (cred->type,
907// cred->data,
908// cred->data_size);
909// char *jwt_body = strtok (jwt_string, delim);
910// jwt_body = strtok (NULL, delim);
911// GNUNET_STRINGS_base64_decode (jwt_body, strlen (jwt_body),
912// (void **) &decoded_jwt);
913// json_val = json_loads (decoded_jwt, JSON_DECODE_ANY, json_err);
914// const char *key;
915// json_t *value;
916// json_object_foreach (json_val, key, value) {
917// if (0 == strcasecmp (key,claim))
918// {
919// val_str = json_dumps (value, JSON_ENCODE_ANY);
920// }
921// }
922// type_str = "String";
923// type = GNUNET_RECLAIM_attribute_typename_to_number (type_str);
924// if (GNUNET_SYSERR == GNUNET_RECLAIM_attribute_string_to_value (type,val_str,
925// (void **) &data
926// ,
927// &data_size))
928// {
929// GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
930// "Attribute value from JWT Parser invalid!\n");
931// GNUNET_RECLAIM_attribute_string_to_value (type,
932// "Error: Referenced Claim Name not Found",
933// (void **) &data,
934// &data_size);
935// attr = GNUNET_RECLAIM_attribute_new (claim, &cred->id,
936// type, data, data_size);
937// attr->id = cred->id;
938// attr->flag = 1;
939// }
940// else
941// {
942// attr = GNUNET_RECLAIM_attribute_new (claim, &cred->id,
943// type, data, data_size);
944// attr->id = cred->id;
945// attr->flag = 1;
946// }
947// return attr;
948//}
949
950
955static void
957 const struct GNUNET_CRYPTO_PublicKey *identity,
958 const struct GNUNET_RECLAIM_Attribute *attr)
959{
960 struct RequestHandle *handle = cls;
961 json_t *attr_obj;
962 const char *type;
963 char *id_str;
964
965 char *tmp_value;
967 attr->data,
968 attr->data_size);
969 attr_obj = json_object ();
970 json_object_set_new (attr_obj, "value", json_string (tmp_value));
971 json_object_set_new (attr_obj, "name", json_string (attr->name));
972
974 json_object_set_new (attr_obj, "flag", json_string ("0"));
975 else
976 json_object_set_new (attr_obj, "flag", json_string ("1"));
978 json_object_set_new (attr_obj, "type", json_string (type));
980 sizeof(attr->id));
981 json_object_set_new (attr_obj, "id", json_string (id_str));
982 GNUNET_free (id_str);
984 sizeof(attr->credential));
985 json_object_set_new (attr_obj, "credential", json_string (id_str));
986 GNUNET_free (id_str);
987 json_array_append (handle->resp_object, attr_obj);
988 json_decref (attr_obj);
989 GNUNET_free (tmp_value);
991}
992
993
1001static void
1003 const char *url,
1004 void *cls)
1005{
1006 const struct GNUNET_CRYPTO_PrivateKey *priv_key;
1007 struct RequestHandle *handle = cls;
1008 struct EgoEntry *ego_entry;
1009 char *identity;
1010
1012 "Getting attributes for %s.\n",
1013 handle->url);
1014 if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) >= strlen (handle->url))
1015 {
1016 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
1018 return;
1019 }
1021
1022 for (ego_entry = ego_head; NULL != ego_entry;
1023 ego_entry = ego_entry->next)
1024 if (0 == strcmp (identity, ego_entry->identifier))
1025 break;
1026 handle->resp_object = json_array ();
1027
1028
1029 if (NULL == ego_entry)
1030 {
1031 // Done
1032 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
1034 return;
1035 }
1036 priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
1038 priv_key,
1040 handle,
1041 &attr_collect,
1042 handle,
1044 handle);
1045}
1046
1047
1055static void
1057 const char *url,
1058 void *cls)
1059{
1060 const struct GNUNET_CRYPTO_PrivateKey *priv_key;
1061 struct RequestHandle *handle = cls;
1062 struct GNUNET_RECLAIM_Attribute attr;
1063 struct EgoEntry *ego_entry;
1064 char *identity_id_str;
1065 char *identity;
1066 char *id;
1067
1068 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting attributes.\n");
1069 if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) >= strlen (handle->url))
1070 {
1071 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
1073 return;
1074 }
1075 identity_id_str =
1076 strdup (handle->url + strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) + 1);
1077 identity = strtok (identity_id_str, "/");
1078 id = strtok (NULL, "/");
1079 if ((NULL == identity) || (NULL == id))
1080 {
1081 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Malformed request.\n");
1082 GNUNET_free (identity_id_str);
1084 return;
1085 }
1086
1087 for (ego_entry = ego_head; NULL != ego_entry;
1088 ego_entry = ego_entry->next)
1089 if (0 == strcmp (identity, ego_entry->identifier))
1090 break;
1091 handle->resp_object = json_array ();
1092 if (NULL == ego_entry)
1093 {
1094 // Done
1095 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
1096 GNUNET_free (identity_id_str);
1098 return;
1099 }
1100 priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
1101 memset (&attr, 0, sizeof(struct GNUNET_RECLAIM_Attribute));
1102 GNUNET_STRINGS_string_to_data (id, strlen (id), &attr.id, sizeof(attr.id));
1103 attr.name = "";
1105 priv_key,
1106 &attr,
1108 handle);
1109 GNUNET_free (identity_id_str);
1110}
1111
1112
1113static void
1115 const char *url,
1116 void *cls)
1117{
1118 const struct GNUNET_CRYPTO_PrivateKey *identity_priv;
1119 struct RequestHandle *handle = cls;
1120 struct EgoEntry *ego_entry;
1121 struct GNUNET_RECLAIM_Ticket *ticket = NULL;
1122 struct GNUNET_CRYPTO_PublicKey iss;
1123 struct GNUNET_CRYPTO_PublicKey tmp_pk;
1124 char term_data[handle->rest_handle->data_size + 1];
1125 json_t *data_json;
1126 json_error_t err;
1127 struct GNUNET_JSON_Specification tktspec[] =
1129
1130 if (0 >= handle->rest_handle->data_size)
1131 {
1133 return;
1134 }
1135
1136 term_data[handle->rest_handle->data_size] = '\0';
1137 GNUNET_memcpy (term_data,
1138 handle->rest_handle->data,
1139 handle->rest_handle->data_size);
1140 data_json = json_loads (term_data, JSON_DECODE_ANY, &err);
1141 if ((NULL == data_json) ||
1142 (GNUNET_OK != GNUNET_JSON_parse (data_json, tktspec, NULL, NULL)))
1143 {
1144 handle->emsg = GNUNET_strdup ("Not a ticket!\n");
1146 GNUNET_JSON_parse_free (tktspec);
1147 if (NULL != data_json)
1148 json_decref (data_json);
1149 return;
1150 }
1151 json_decref (data_json);
1152 if (NULL == ticket)
1153 {
1155 "Unable to parse ticket from %s\n",
1156 term_data);
1158 return;
1159 }
1160
1162
1163 for (ego_entry = ego_head; NULL != ego_entry;
1164 ego_entry = ego_entry->next)
1165 {
1166 GNUNET_IDENTITY_ego_get_public_key (ego_entry->ego, &tmp_pk);
1167 if (0 == memcmp (&iss,
1168 &tmp_pk,
1169 sizeof(struct GNUNET_CRYPTO_PublicKey)))
1170 break;
1171 }
1172 if (NULL == ego_entry)
1173 {
1174 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Identity unknown\n");
1175 GNUNET_JSON_parse_free (tktspec);
1176 return;
1177 }
1178 identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
1179
1181 identity_priv,
1182 ticket,
1184 handle);
1185 GNUNET_JSON_parse_free (tktspec);
1186}
1187
1188
1189static void
1191 const struct GNUNET_CRYPTO_PublicKey *identity,
1192 const struct GNUNET_RECLAIM_Attribute *attr,
1193 const struct GNUNET_RECLAIM_Presentation *presentation)
1194{
1195 struct RequestHandle *handle = cls;
1196 char *val_str;
1197 json_t *value;
1198
1199 if (NULL == identity)
1200 {
1202 return;
1203 }
1204
1205 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute: %s\n", attr->name);
1207 attr->data,
1208 attr->data_size);
1209 if (NULL == val_str)
1210 {
1212 "Failed to parse value for: %s\n",
1213 attr->name);
1214 return;
1215 }
1216 value = json_string (val_str);
1217 json_object_set_new (handle->resp_object, attr->name, value);
1218 json_decref (value);
1219 GNUNET_free (val_str);
1220}
1221
1222
1223static void
1225 const char *url,
1226 void *cls)
1227{
1228 struct RequestHandle *handle = cls;
1230 char term_data[handle->rest_handle->data_size + 1];
1231 const char *rp_uri;
1232 json_t *data_json;
1233 json_error_t err;
1234 struct GNUNET_JSON_Specification tktspec[] =
1236 GNUNET_JSON_spec_string ("rp_uri", &rp_uri),
1238
1239 if (0 >= handle->rest_handle->data_size)
1240 {
1242 return;
1243 }
1244
1245 term_data[handle->rest_handle->data_size] = '\0';
1246 GNUNET_memcpy (term_data,
1247 handle->rest_handle->data,
1248 handle->rest_handle->data_size);
1249 data_json = json_loads (term_data, JSON_DECODE_ANY, &err);
1250 if (NULL == data_json)
1251 {
1253 "Unable to parse JSON Object from %s\n",
1254 term_data);
1256 return;
1257 }
1258 if (GNUNET_OK != GNUNET_JSON_parse (data_json, tktspec, NULL, NULL))
1259 {
1260 handle->emsg = GNUNET_strdup ("Not a ticket!\n");
1262 GNUNET_JSON_parse_free (tktspec);
1263 json_decref (data_json);
1264 return;
1265 }
1266 handle->resp_object = json_object ();
1268 ticket,
1269 rp_uri,
1270 &consume_cont,
1271 handle);
1272 GNUNET_JSON_parse_free (tktspec);
1273}
1274
1275
1283static void
1285 const char *url,
1286 void *cls)
1287{
1288 struct MHD_Response *resp;
1289 struct RequestHandle *handle = cls;
1290
1291 // For now, independent of path return all options
1292 resp = GNUNET_REST_create_response (NULL);
1293 GNUNET_assert (MHD_NO != MHD_add_response_header (resp,
1294 "Access-Control-Allow-Methods",
1295 allow_methods));
1296 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
1298 return;
1299}
1300
1301
1334static void
1335list_ego (void *cls,
1336 struct GNUNET_IDENTITY_Ego *ego,
1337 void **ctx,
1338 const char *identifier)
1339{
1340 struct EgoEntry *ego_entry;
1342
1343 if (NULL == ego)
1344 {
1346 return;
1347 }
1349 {
1350 ego_entry = GNUNET_new (struct EgoEntry);
1353 ego_entry->ego = ego;
1354 ego_entry->identifier = GNUNET_strdup (identifier);
1356 ego_tail,
1357 ego_entry);
1358 }
1359 /* Ego renamed or added */
1360 if (identifier != NULL)
1361 {
1362 for (ego_entry = ego_head; NULL != ego_entry;
1363 ego_entry = ego_entry->next)
1364 {
1365 if (ego_entry->ego == ego)
1366 {
1367 /* Rename */
1368 GNUNET_free (ego_entry->identifier);
1369 ego_entry->identifier = GNUNET_strdup (identifier);
1370 break;
1371 }
1372 }
1373 if (NULL == ego_entry)
1374 {
1375 /* Add */
1376 ego_entry = GNUNET_new (struct EgoEntry);
1379 ego_entry->ego = ego;
1380 ego_entry->identifier = GNUNET_strdup (identifier);
1382 ego_tail,
1383 ego_entry);
1384 }
1385 }
1386 else
1387 {
1388 /* Delete */
1389 for (ego_entry = ego_head; NULL != ego_entry;
1390 ego_entry = ego_entry->next)
1391 {
1392 if (ego_entry->ego == ego)
1393 break;
1394 }
1395 if (NULL == ego_entry)
1396 return; /* Not found */
1397
1399 ego_tail,
1400 ego_entry);
1401 GNUNET_free (ego_entry->identifier);
1402 GNUNET_free (ego_entry->keystring);
1403 GNUNET_free (ego_entry);
1404 return;
1405 }
1406
1407}
1408
1409
1412 struct GNUNET_REST_RequestHandle *rest_handle,
1414 void *proc_cls)
1415{
1416 struct RequestHandle *handle = GNUNET_new (struct RequestHandle);
1418 static const struct GNUNET_REST_RequestHandler handlers[] =
1419 { { MHD_HTTP_METHOD_GET,
1421 { MHD_HTTP_METHOD_POST,
1423 { MHD_HTTP_METHOD_DELETE,
1425 { MHD_HTTP_METHOD_GET,
1427 { MHD_HTTP_METHOD_POST,
1429 { MHD_HTTP_METHOD_DELETE,
1431 { MHD_HTTP_METHOD_GET,
1433 { MHD_HTTP_METHOD_POST,
1435 { MHD_HTTP_METHOD_POST,
1437 { MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_RECLAIM, &options_cont },
1439
1440 handle->response_code = 0;
1442 handle->proc_cls = proc_cls;
1443 handle->proc = proc;
1444 handle->rest_handle = rest_handle;
1445
1446 handle->url = GNUNET_strdup (rest_handle->url);
1447 if (handle->url[strlen (handle->url) - 1] == '/')
1448 handle->url[strlen (handle->url) - 1] = '\0';
1449 handle->timeout_task =
1453 handle);
1454 if (GNUNET_NO ==
1455 GNUNET_REST_handle_request (handle->rest_handle, handlers, &err, handle))
1456 {
1458 return GNUNET_NO;
1459 }
1460
1461 return GNUNET_YES;
1462}
1463
1464
1471void *
1473{
1474 static struct Plugin plugin;
1475 struct GNUNET_REST_Plugin *api;
1476
1477 rcfg = c;
1478 if (NULL != plugin.cfg)
1479 return NULL; /* can only initialize once! */
1480 memset (&plugin, 0, sizeof(struct Plugin));
1481 plugin.cfg = rcfg;
1482 api = GNUNET_new (struct GNUNET_REST_Plugin);
1483 api->cls = &plugin;
1486 "%s, %s, %s, %s, %s",
1487 MHD_HTTP_METHOD_GET,
1488 MHD_HTTP_METHOD_POST,
1489 MHD_HTTP_METHOD_PUT,
1490 MHD_HTTP_METHOD_DELETE,
1491 MHD_HTTP_METHOD_OPTIONS);
1496 _ ("Identity Provider REST API initialized\n"));
1497 return api;
1498}
1499
1500
1507void
1509{
1510 struct Plugin *plugin = api->cls;
1511 struct RequestHandle *request;
1512 struct EgoEntry *ego_entry;
1513 struct EgoEntry *ego_tmp;
1514
1515 plugin->cfg = NULL;
1516 while (NULL != (request = requests_head))
1517 do_error (request);
1518 if (NULL != idp)
1520 if (NULL != identity_handle)
1522 for (ego_entry = ego_head; NULL != ego_entry;)
1523 {
1524 ego_tmp = ego_entry;
1525 ego_entry = ego_entry->next;
1526 GNUNET_free (ego_tmp->identifier);
1527 GNUNET_free (ego_tmp->keystring);
1528 GNUNET_free (ego_tmp);
1529 }
1530
1532 GNUNET_free (api);
1534 "Identity Provider REST plugin is finished\n");
1535}
1536
1537
1538/* 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 gnutls_certificate_credentials_t cred
The credential.
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 struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
static struct GNUNET_RECLAIM_Ticket ticket
Ticket to consume.
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:100
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:379
#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
#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.
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.
const char * GNUNET_RECLAIM_attribute_number_to_typename(uint32_t type)
Convert a type number to the corresponding type string.
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:980
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:1304
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:1277
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:787
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:812
#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.
void * REST_reclaim_init(const struct GNUNET_CONFIGURATION_Handle *c)
Entry point for the plugin.
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.
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_done(struct GNUNET_REST_Plugin *api)
Exit point from 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)
Parse a JWT and return the respective claim value as Attribute.
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
const char * name
The name of the credential.
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
void * cls
The closure of the plugin.
const char * name
Plugin name.
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:47
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:56
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:76
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:71
struct GNUNET_RECLAIM_AttributeIterator * attr_it
Attribute iterator.
GNUNET_REST_ResultProcessor proc
The plugin result processor.
Definition: config_plugin.c:66
struct RequestHandle * next
DLL.
Definition: config_plugin.c:51
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:61
char * url
The URL.
Definition: config_plugin.c:81
struct GNUNET_TIME_Relative timeout
Desired timeout for the lookup (default is no timeout).
Definition: gns_plugin.c:117