aboutsummaryrefslogtreecommitdiff
path: root/src/reclaim/gnunet-reclaim.c
diff options
context:
space:
mode:
authorMartin Schanzenbach <schanzen@gnunet.org>2023-10-19 12:49:08 +0200
committerMartin Schanzenbach <schanzen@gnunet.org>2023-10-19 12:49:08 +0200
commit39e327905f421c470b9cbd5c1ea548261bcae026 (patch)
treefa0df2a80fe4c785e12c609f619eb5f95e55904c /src/reclaim/gnunet-reclaim.c
parenta2de0769515468c733b72698f04b24d03190f719 (diff)
downloadgnunet-39e327905f421c470b9cbd5c1ea548261bcae026.tar.gz
gnunet-39e327905f421c470b9cbd5c1ea548261bcae026.zip
BUILD: Move reclaim to service
Diffstat (limited to 'src/reclaim/gnunet-reclaim.c')
-rw-r--r--src/reclaim/gnunet-reclaim.c928
1 files changed, 0 insertions, 928 deletions
diff --git a/src/reclaim/gnunet-reclaim.c b/src/reclaim/gnunet-reclaim.c
deleted file mode 100644
index efb2c2902..000000000
--- a/src/reclaim/gnunet-reclaim.c
+++ /dev/null
@@ -1,928 +0,0 @@
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 */
20/**
21 * @author Martin Schanzenbach
22 * @file src/reclaim/gnunet-reclaim.c
23 * @brief Identity Provider utility
24 *
25 */
26#include "platform.h"
27#include <inttypes.h>
28
29#include "gnunet_util_lib.h"
30
31#include "gnunet_identity_service.h"
32#include "gnunet_namestore_service.h"
33#include "gnunet_reclaim_service.h"
34#include "gnunet_signatures.h"
35/**
36 * return value
37 */
38static int ret;
39
40/**
41 * List attribute flag
42 */
43static int list;
44
45/**
46 * List credentials flag
47 */
48static int list_credentials;
49
50/**
51 * Credential ID string
52 */
53static char *credential_id;
54
55/**
56 * Credential ID
57 */
58static struct GNUNET_RECLAIM_Identifier credential;
59
60/**
61 * Credential name
62 */
63static char *credential_name;
64
65/**
66 * Credential type
67 */
68static char *credential_type;
69
70/**
71 * Credential exists
72 */
73static int credential_exists;
74
75/**
76 * Relying party
77 */
78static char *rp;
79
80/**
81 * The attribute
82 */
83static char *attr_name;
84
85/**
86 * Attribute value
87 */
88static char *attr_value;
89
90/**
91 * Attributes to issue
92 */
93static char *issue_attrs;
94
95/**
96 * Ticket to consume
97 */
98static char *consume_ticket;
99
100/**
101 * Attribute type
102 */
103static char *type_str;
104
105/**
106 * Ticket to revoke
107 */
108static char *revoke_ticket;
109
110/**
111 * Ticket listing
112 */
113static int list_tickets;
114
115/**
116 * Ego name
117 */
118static char *ego_name;
119
120/**
121 * Identity handle
122 */
123static struct GNUNET_IDENTITY_Handle *identity_handle;
124
125/**
126 * reclaim handle
127 */
128static struct GNUNET_RECLAIM_Handle *reclaim_handle;
129
130/**
131 * reclaim operation
132 */
133static struct GNUNET_RECLAIM_Operation *reclaim_op;
134
135/**
136 * Attribute iterator
137 */
138static struct GNUNET_RECLAIM_AttributeIterator *attr_iterator;
139
140/**
141 * Credential iterator
142 */
143static struct GNUNET_RECLAIM_CredentialIterator *cred_iterator;
144
145
146/**
147 * Ticket iterator
148 */
149static struct GNUNET_RECLAIM_TicketIterator *ticket_iterator;
150
151
152/**
153 * ego private key
154 */
155static const struct GNUNET_CRYPTO_PrivateKey *pkey;
156
157/**
158 * rp public key
159 */
160static struct GNUNET_CRYPTO_PublicKey rp_key;
161
162/**
163 * Ticket to consume
164 */
165static struct GNUNET_RECLAIM_Ticket ticket;
166
167/**
168 * Attribute list
169 */
170static struct GNUNET_RECLAIM_AttributeList *attr_list;
171
172/**
173 * Attribute expiration interval
174 */
175static struct GNUNET_TIME_Relative exp_interval;
176
177/**
178 * Timeout task
179 */
180static struct GNUNET_SCHEDULER_Task *timeout;
181
182/**
183 * Cleanup task
184 */
185static struct GNUNET_SCHEDULER_Task *cleanup_task;
186
187/**
188 * Claim to store
189 */
190struct GNUNET_RECLAIM_Attribute *claim;
191
192/**
193 * Claim to delete
194 */
195static char *attr_delete;
196
197/**
198 * Claim object to delete
199 */
200static struct GNUNET_RECLAIM_Attribute *attr_to_delete;
201
202static void
203do_cleanup (void *cls)
204{
205 cleanup_task = NULL;
206 if (NULL != timeout)
207 GNUNET_SCHEDULER_cancel (timeout);
208 if (NULL != reclaim_op)
209 GNUNET_RECLAIM_cancel (reclaim_op);
210 if (NULL != attr_iterator)
211 GNUNET_RECLAIM_get_attributes_stop (attr_iterator);
212 if (NULL != cred_iterator)
213 GNUNET_RECLAIM_get_credentials_stop (cred_iterator);
214 if (NULL != ticket_iterator)
215 GNUNET_RECLAIM_ticket_iteration_stop (ticket_iterator);
216 if (NULL != reclaim_handle)
217 GNUNET_RECLAIM_disconnect (reclaim_handle);
218 if (NULL != identity_handle)
219 GNUNET_IDENTITY_disconnect (identity_handle);
220 if (NULL != attr_list)
221 {
222 GNUNET_RECLAIM_attribute_list_destroy (attr_list);
223 attr_list = NULL;
224 }
225 if (NULL != attr_to_delete)
226 GNUNET_free (attr_to_delete);
227 if (NULL == credential_type)
228 GNUNET_free (credential_type);
229}
230
231
232static void
233ticket_issue_cb (void *cls,
234 const struct GNUNET_RECLAIM_Ticket *ticket,
235 const struct GNUNET_RECLAIM_PresentationList *presentations)
236{
237 char *ticket_str;
238
239 reclaim_op = NULL;
240 if (NULL != ticket)
241 {
242 ticket_str =
243 GNUNET_STRINGS_data_to_string_alloc (ticket,
244 sizeof(
245 struct GNUNET_RECLAIM_Ticket));
246 printf ("%s\n", ticket_str);
247 GNUNET_free (ticket_str);
248 }
249 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
250}
251
252
253static void
254store_cont (void *cls, int32_t success, const char *emsg)
255{
256 reclaim_op = NULL;
257 if (GNUNET_SYSERR == success)
258 {
259 fprintf (stderr, "%s\n", emsg);
260 }
261 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
262}
263
264
265static void
266process_attrs (void *cls,
267 const struct GNUNET_CRYPTO_PublicKey *identity,
268 const struct GNUNET_RECLAIM_Attribute *attr,
269 const struct GNUNET_RECLAIM_Presentation *presentation)
270{
271 char *value_str;
272 char *id;
273 const char *attr_type;
274
275 if (NULL == identity)
276 {
277 reclaim_op = NULL;
278 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
279 return;
280 }
281 if (NULL == attr)
282 {
283 ret = 1;
284 return;
285 }
286 attr_type = GNUNET_RECLAIM_attribute_number_to_typename (attr->type);
287 id = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(attr->id));
288 value_str = NULL;
289 if (NULL == presentation)
290 {
291 value_str = GNUNET_RECLAIM_attribute_value_to_string (attr->type,
292 attr->data,
293 attr->data_size);
294 }
295 else
296 {
297 struct GNUNET_RECLAIM_AttributeListEntry *ale;
298 struct GNUNET_RECLAIM_AttributeList *al
299 = GNUNET_RECLAIM_presentation_get_attributes (presentation);
300
301 for (ale = al->list_head; NULL != ale; ale = ale->next)
302 {
303 if (0 != strncmp (attr->data, ale->attribute->name, attr->data_size))
304 continue;
305 value_str
306 = GNUNET_RECLAIM_attribute_value_to_string (ale->attribute->type,
307 ale->attribute->data,
308 ale->attribute->data_size);
309 break;
310 }
311 }
312 fprintf (stdout,
313 "Name: %s; Value: %s (%s); Flag %u; ID: %s %s\n",
314 attr->name,
315 (NULL != value_str) ? value_str : "???",
316 attr_type,
317 attr->flag,
318 id,
319 (NULL == presentation) ? "" : "(ATTESTED)");
320 GNUNET_free (value_str);
321 GNUNET_free (id);
322}
323
324
325static void
326ticket_iter_err (void *cls)
327{
328 ticket_iterator = NULL;
329 fprintf (stderr, "Failed to iterate over tickets\n");
330 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
331}
332
333
334static void
335ticket_iter_fin (void *cls)
336{
337 ticket_iterator = NULL;
338 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
339}
340
341
342static void
343ticket_iter (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket)
344{
345 char *aud;
346 char *ref;
347 char *tkt;
348
349 aud =
350 GNUNET_STRINGS_data_to_string_alloc (&ticket->audience,
351 sizeof(struct
352 GNUNET_CRYPTO_PublicKey));
353 ref = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof(ticket->rnd));
354 tkt =
355 GNUNET_STRINGS_data_to_string_alloc (ticket,
356 sizeof(struct GNUNET_RECLAIM_Ticket));
357 fprintf (stdout, "Ticket: %s | ID: %s | Audience: %s\n", tkt, ref, aud);
358 GNUNET_free (aud);
359 GNUNET_free (ref);
360 GNUNET_free (tkt);
361 GNUNET_RECLAIM_ticket_iteration_next (ticket_iterator);
362}
363
364
365static void
366iter_error (void *cls)
367{
368 attr_iterator = NULL;
369 cred_iterator = NULL;
370 fprintf (stderr, "Failed\n");
371
372 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
373}
374
375
376static void
377timeout_task (void *cls)
378{
379 timeout = NULL;
380 ret = 1;
381 fprintf (stderr, "Timeout\n");
382 if (NULL == cleanup_task)
383 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
384}
385
386
387static void
388process_rvk (void *cls, int success, const char *msg)
389{
390 reclaim_op = NULL;
391 if (GNUNET_OK != success)
392 {
393 fprintf (stderr, "Revocation failed.\n");
394 ret = 1;
395 }
396 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
397}
398
399
400static void
401process_delete (void *cls, int success, const char *msg)
402{
403 reclaim_op = NULL;
404 if (GNUNET_OK != success)
405 {
406 fprintf (stderr, "Deletion failed.\n");
407 ret = 1;
408 }
409 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
410}
411
412
413static void
414iter_finished (void *cls)
415{
416 char *data;
417 size_t data_size;
418 int type;
419
420 attr_iterator = NULL;
421 if (list)
422 {
423 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
424 return;
425 }
426
427 if (issue_attrs)
428 {
429 reclaim_op = GNUNET_RECLAIM_ticket_issue (reclaim_handle,
430 pkey,
431 &rp_key,
432 attr_list,
433 &ticket_issue_cb,
434 NULL);
435 return;
436 }
437 if (consume_ticket)
438 {
439 reclaim_op = GNUNET_RECLAIM_ticket_consume (reclaim_handle,
440 pkey,
441 &ticket,
442 &process_attrs,
443 NULL);
444 timeout = GNUNET_SCHEDULER_add_delayed (
445 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10),
446 &timeout_task,
447 NULL);
448 return;
449 }
450 if (revoke_ticket)
451 {
452 reclaim_op = GNUNET_RECLAIM_ticket_revoke (reclaim_handle,
453 pkey,
454 &ticket,
455 &process_rvk,
456 NULL);
457 return;
458 }
459 if (attr_delete)
460 {
461 if (NULL == attr_to_delete)
462 {
463 fprintf (stdout, "No such attribute ``%s''\n", attr_delete);
464 GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
465 return;
466 }
467 reclaim_op = GNUNET_RECLAIM_attribute_delete (reclaim_handle,
468 pkey,
469 attr_to_delete,
470 &process_delete,
471 NULL);
472 return;
473 }
474 if (attr_name)
475 {
476 if (NULL == type_str)
477 type = GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING;
478 else
479 type = GNUNET_RECLAIM_attribute_typename_to_number (type_str);
480
481 GNUNET_assert (GNUNET_SYSERR !=
482 GNUNET_RECLAIM_attribute_string_to_value (type,
483 attr_value,
484 (void **) &data,
485 &data_size));
486 if (NULL != claim)
487 {
488 claim->type = type;
489 claim->data = data;
490 claim->data_size = data_size;
491 }
492 else
493 {
494 claim =
495 GNUNET_RECLAIM_attribute_new (attr_name, NULL, type, data, data_size);
496 }
497 if (NULL != credential_id)
498 {
499 claim->credential = credential;
500 }
501 reclaim_op = GNUNET_RECLAIM_attribute_store (reclaim_handle,
502 pkey,
503 claim,
504 &exp_interval,
505 &store_cont,
506 NULL);
507 GNUNET_free (data);
508 GNUNET_free (claim);
509 return;
510 }
511 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
512}
513
514
515static void
516iter_cb (void *cls,
517 const struct GNUNET_CRYPTO_PublicKey *identity,
518 const struct GNUNET_RECLAIM_Attribute *attr)
519{
520 struct GNUNET_RECLAIM_AttributeListEntry *le;
521 char *attrs_tmp;
522 char *attr_str;
523 char *label;
524 char *id;
525 const char *attr_type;
526
527 if ((NULL != attr_name) && (NULL == claim))
528 {
529 if (0 == strcasecmp (attr_name, attr->name))
530 {
531 claim = GNUNET_RECLAIM_attribute_new (attr->name,
532 &attr->credential,
533 attr->type,
534 attr->data,
535 attr->data_size);
536 claim->id = attr->id;
537 }
538 }
539 else if (issue_attrs)
540 {
541 attrs_tmp = GNUNET_strdup (issue_attrs);
542 attr_str = strtok (attrs_tmp, ",");
543 while (NULL != attr_str)
544 {
545 if (0 != strcasecmp (attr_str, attr->name))
546 {
547 attr_str = strtok (NULL, ",");
548 continue;
549 }
550 le = GNUNET_new (struct GNUNET_RECLAIM_AttributeListEntry);
551 le->attribute = GNUNET_RECLAIM_attribute_new (attr->name,
552 &attr->credential,
553 attr->type,
554 attr->data,
555 attr->data_size);
556 le->attribute->flag = attr->flag;
557 le->attribute->id = attr->id;
558 GNUNET_CONTAINER_DLL_insert (attr_list->list_head,
559 attr_list->list_tail,
560 le);
561 break;
562 }
563 GNUNET_free (attrs_tmp);
564 }
565 else if (attr_delete && (NULL == attr_to_delete))
566 {
567 label = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(attr->id));
568 if (0 == strcasecmp (attr_delete, label))
569 {
570 attr_to_delete = GNUNET_RECLAIM_attribute_new (attr->name,
571 &attr->credential,
572 attr->type,
573 attr->data,
574 attr->data_size);
575 attr_to_delete->id = attr->id;
576 }
577 GNUNET_free (label);
578 }
579 else if (list)
580 {
581 attr_str = GNUNET_RECLAIM_attribute_value_to_string (attr->type,
582 attr->data,
583 attr->data_size);
584 attr_type = GNUNET_RECLAIM_attribute_number_to_typename (attr->type);
585 id = GNUNET_STRINGS_data_to_string_alloc (&attr->id, sizeof(attr->id));
586 if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&attr->credential))
587 {
588 fprintf (stdout,
589 "%s: ``%s'' (%s); ID: %s\n",
590 attr->name,
591 attr_str,
592 attr_type,
593 id);
594 }
595 else
596 {
597 char *cred_id =
598 GNUNET_STRINGS_data_to_string_alloc (&attr->credential,
599 sizeof(attr->credential));
600 fprintf (stdout,
601 "%s: ``%s'' in credential presentation `%s' (%s); ID: %s\n",
602 attr->name,
603 attr_str,
604 cred_id,
605 attr_type,
606 id);
607 GNUNET_free (cred_id);
608
609 }
610 GNUNET_free (id);
611 }
612 GNUNET_RECLAIM_get_attributes_next (attr_iterator);
613}
614
615
616static void
617cred_iter_finished (void *cls)
618{
619 cred_iterator = NULL;
620
621 // Add new credential
622 if ((NULL != credential_name) &&
623 (NULL != attr_value))
624 {
625 enum GNUNET_RECLAIM_CredentialType ctype =
626 GNUNET_RECLAIM_credential_typename_to_number (credential_type);
627 struct GNUNET_RECLAIM_Credential *credential =
628 GNUNET_RECLAIM_credential_new (credential_name,
629 ctype,
630 attr_value,
631 strlen (attr_value));
632 reclaim_op = GNUNET_RECLAIM_credential_store (reclaim_handle,
633 pkey,
634 credential,
635 &exp_interval,
636 store_cont,
637 NULL);
638 return;
639
640 }
641 if (list_credentials)
642 {
643 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
644 return;
645 }
646 attr_iterator = GNUNET_RECLAIM_get_attributes_start (reclaim_handle,
647 pkey,
648 &iter_error,
649 NULL,
650 &iter_cb,
651 NULL,
652 &iter_finished,
653 NULL);
654
655}
656
657
658static void
659cred_iter_cb (void *cls,
660 const struct GNUNET_CRYPTO_PublicKey *identity,
661 const struct GNUNET_RECLAIM_Credential *cred)
662{
663 char *cred_str;
664 char *attr_str;
665 char *id;
666 const char *cred_type;
667 struct GNUNET_RECLAIM_AttributeListEntry *ale;
668
669 if (GNUNET_YES == GNUNET_RECLAIM_id_is_equal (&credential,
670 &cred->id))
671 credential_exists = GNUNET_YES;
672 if (list_credentials)
673 {
674 cred_str = GNUNET_RECLAIM_credential_value_to_string (cred->type,
675 cred->data,
676 cred->data_size);
677 cred_type = GNUNET_RECLAIM_credential_number_to_typename (cred->type);
678 id = GNUNET_STRINGS_data_to_string_alloc (&cred->id, sizeof(cred->id));
679 fprintf (stdout,
680 "%s: ``%s'' (%s); ID: %s\n",
681 cred->name,
682 cred_str,
683 cred_type,
684 id);
685 struct GNUNET_RECLAIM_AttributeList *attrs =
686 GNUNET_RECLAIM_credential_get_attributes (cred);
687 if (NULL != attrs)
688 {
689 fprintf (stdout,
690 "\t Attributes:\n");
691 for (ale = attrs->list_head; NULL != ale; ale = ale->next)
692 {
693 attr_str = GNUNET_RECLAIM_attribute_value_to_string (
694 ale->attribute->type,
695 ale->attribute->data,
696 ale->attribute->data_size);
697 fprintf (stdout,
698 "\t %s: %s\n", ale->attribute->name, attr_str);
699 GNUNET_free (attr_str);
700 }
701 GNUNET_RECLAIM_attribute_list_destroy (attrs);
702 }
703 GNUNET_free (id);
704 }
705 GNUNET_RECLAIM_get_credentials_next (cred_iterator);
706}
707
708
709static void
710start_process ()
711{
712 if (NULL == pkey)
713 {
714 fprintf (stderr, "Ego %s not found\n", ego_name);
715 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
716 return;
717 }
718 if (NULL == credential_type)
719 credential_type = GNUNET_strdup ("JWT");
720 credential = GNUNET_RECLAIM_ID_ZERO;
721 if (NULL != credential_id)
722 GNUNET_STRINGS_string_to_data (credential_id,
723 strlen (credential_id),
724 &credential, sizeof(credential));
725 credential_exists = GNUNET_NO;
726 if (list_tickets)
727 {
728 ticket_iterator = GNUNET_RECLAIM_ticket_iteration_start (reclaim_handle,
729 pkey,
730 &ticket_iter_err,
731 NULL,
732 &ticket_iter,
733 NULL,
734 &ticket_iter_fin,
735 NULL);
736 return;
737 }
738
739 if ((NULL != rp) &&
740 (GNUNET_OK !=
741 GNUNET_CRYPTO_public_key_from_string (rp, &rp_key)) )
742 {
743 fprintf (stderr, "%s is not a public key!\n", rp);
744 cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
745 return;
746 }
747 if (NULL != consume_ticket)
748 GNUNET_STRINGS_string_to_data (consume_ticket,
749 strlen (consume_ticket),
750 &ticket,
751 sizeof(struct GNUNET_RECLAIM_Ticket));
752 if (NULL != revoke_ticket)
753 GNUNET_STRINGS_string_to_data (revoke_ticket,
754 strlen (revoke_ticket),
755 &ticket,
756 sizeof(struct GNUNET_RECLAIM_Ticket));
757
758 attr_list = GNUNET_new (struct GNUNET_RECLAIM_AttributeList);
759 claim = NULL;
760 cred_iterator = GNUNET_RECLAIM_get_credentials_start (reclaim_handle,
761 pkey,
762 &iter_error,
763 NULL,
764 &cred_iter_cb,
765 NULL,
766 &cred_iter_finished,
767 NULL);
768
769}
770
771
772static int init = GNUNET_YES;
773
774static void
775ego_cb (void *cls,
776 struct GNUNET_IDENTITY_Ego *ego,
777 void **ctx,
778 const char *name)
779{
780 if (NULL == name)
781 {
782 if (GNUNET_YES == init)
783 {
784 init = GNUNET_NO;
785 start_process ();
786 }
787 return;
788 }
789 if (0 != strcmp (name, ego_name))
790 return;
791 pkey = GNUNET_IDENTITY_ego_get_private_key (ego);
792}
793
794
795static void
796run (void *cls,
797 char *const *args,
798 const char *cfgfile,
799 const struct GNUNET_CONFIGURATION_Handle *c)
800{
801 ret = 0;
802 if (NULL == ego_name)
803 {
804 ret = 1;
805 fprintf (stderr, _ ("Ego is required\n"));
806 return;
807 }
808
809 if ((NULL == attr_value) && (NULL != attr_name))
810 {
811 ret = 1;
812 fprintf (stderr, _ ("Attribute value missing!\n"));
813 return;
814 }
815
816 if ((NULL == rp) && (NULL != issue_attrs))
817 {
818 ret = 1;
819 fprintf (stderr, _ ("Requesting party key is required!\n"));
820 return;
821 }
822
823 reclaim_handle = GNUNET_RECLAIM_connect (c);
824 // Get Ego
825 identity_handle = GNUNET_IDENTITY_connect (c, &ego_cb, NULL);
826}
827
828
829int
830main (int argc, char *const argv[])
831{
832 exp_interval = GNUNET_TIME_UNIT_HOURS;
833 struct GNUNET_GETOPT_CommandLineOption options[] = {
834 GNUNET_GETOPT_option_string ('a',
835 "add",
836 "NAME",
837 gettext_noop ("Add or update an attribute NAME"),
838 &attr_name),
839 GNUNET_GETOPT_option_string ('d',
840 "delete",
841 "ID",
842 gettext_noop ("Delete the attribute with ID"),
843 &attr_delete),
844 GNUNET_GETOPT_option_string ('V',
845 "value",
846 "VALUE",
847 gettext_noop ("The attribute VALUE"),
848 &attr_value),
849 GNUNET_GETOPT_option_string ('e',
850 "ego",
851 "EGO",
852 gettext_noop ("The EGO to use"),
853 &ego_name),
854 GNUNET_GETOPT_option_string ('r',
855 "rp",
856 "RP",
857 gettext_noop (
858 "Specify the relying party for issue"),
859 &rp),
860 GNUNET_GETOPT_option_flag ('D',
861 "dump",
862 gettext_noop ("List attributes for EGO"),
863 &list),
864 GNUNET_GETOPT_option_flag ('A',
865 "credentials",
866 gettext_noop ("List credentials for EGO"),
867 &list_credentials),
868 GNUNET_GETOPT_option_string ('I',
869 "credential-id",
870 "CREDENTIAL_ID",
871 gettext_noop (
872 "Credential to use for attribute"),
873 &credential_id),
874 GNUNET_GETOPT_option_string ('N',
875 "credential-name",
876 "NAME",
877 gettext_noop ("Credential name"),
878 &credential_name),
879 GNUNET_GETOPT_option_string ('i',
880 "issue",
881 "A1,A2,...",
882 gettext_noop (
883 "Issue a ticket for a set of attributes separated by comma"),
884 &issue_attrs),
885 GNUNET_GETOPT_option_string ('C',
886 "consume",
887 "TICKET",
888 gettext_noop ("Consume a ticket"),
889 &consume_ticket),
890 GNUNET_GETOPT_option_string ('R',
891 "revoke",
892 "TICKET",
893 gettext_noop ("Revoke a ticket"),
894 &revoke_ticket),
895 GNUNET_GETOPT_option_string ('t',
896 "type",
897 "TYPE",
898 gettext_noop ("Type of attribute"),
899 &type_str),
900 GNUNET_GETOPT_option_string ('u',
901 "credential-type",
902 "TYPE",
903 gettext_noop ("Type of credential"),
904 &credential_type),
905 GNUNET_GETOPT_option_flag ('T',
906 "tickets",
907 gettext_noop ("List tickets of ego"),
908 &list_tickets),
909 GNUNET_GETOPT_option_relative_time ('E',
910 "expiration",
911 "INTERVAL",
912 gettext_noop (
913 "Expiration interval of the attribute"),
914 &exp_interval),
915
916 GNUNET_GETOPT_OPTION_END
917 };
918 if (GNUNET_OK != GNUNET_PROGRAM_run (argc,
919 argv,
920 "gnunet-reclaim",
921 _ ("re:claimID command line tool"),
922 options,
923 &run,
924 NULL))
925 return 1;
926 else
927 return ret;
928}