GNUnet 0.21.1
reclaim_plugin.c File Reference
#include "platform.h"
#include "microhttpd.h"
#include <inttypes.h>
#include <jansson.h>
#include "gnunet_gns_service.h"
#include "gnunet_gnsrecord_lib.h"
#include "gnunet_identity_service.h"
#include "gnunet_reclaim_lib.h"
#include "gnunet_reclaim_service.h"
#include "gnunet_rest_lib.h"
#include "gnunet_rest_plugin.h"
#include "gnunet_signatures.h"
#include "json_reclaim.h"
Include dependency graph for reclaim_plugin.c:

Go to the source code of this file.

Data Structures

struct  Plugin
 Handle for a plugin. More...
 
struct  EgoEntry
 The default namestore ego. More...
 
struct  RequestHandle
 The request handle. More...
 

Macros

#define GNUNET_REST_API_NS_RECLAIM   "/reclaim"
 REST root namespace. More...
 
#define GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES   "/reclaim/attributes"
 Attribute namespace. More...
 
#define GNUNET_REST_API_NS_RECLAIM_CREDENTIAL   "/reclaim/credential"
 Credential namespace. More...
 
#define GNUNET_REST_API_NS_IDENTITY_TICKETS   "/reclaim/tickets"
 Ticket namespace. More...
 
#define GNUNET_REST_API_NS_IDENTITY_REVOKE   "/reclaim/revoke"
 Revoke namespace. More...
 
#define GNUNET_REST_API_NS_IDENTITY_CONSUME   "/reclaim/consume"
 Revoke namespace. More...
 
#define ID_REST_STATE_INIT   0
 State while collecting all egos. More...
 
#define ID_REST_STATE_POST_INIT   1
 Done collecting egos. More...
 

Functions

static void cleanup_handle (void *cls)
 Cleanup lookup handle. More...
 
static void do_error (void *cls)
 Task run on error, sends error message. More...
 
static void do_timeout (void *cls)
 Task run on timeout, sends error message. More...
 
static void collect_error_cb (void *cls)
 
static void finished_cont (void *cls, int32_t success, const char *emsg)
 
static void delete_finished_cb (void *cls, int32_t success, const char *emsg)
 
static void return_response (void *cls)
 Return attributes for identity. More...
 
static void collect_finished_cb (void *cls)
 
static void ticket_collect (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket, const char *rp_uri)
 Collect all attributes for an ego. More...
 
static void add_credential_cont (struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
 
static void cred_collect (void *cls, const struct GNUNET_CRYPTO_PublicKey *identity, const struct GNUNET_RECLAIM_Credential *cred)
 Collect all credentials for an ego. More...
 
static void list_credential_cont (struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
 Lists credential for identity request. More...
 
static void delete_credential_cont (struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
 Deletes credential from an identity. More...
 
static void list_tickets_cont (struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
 List tickets for identity request. More...
 
static void add_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
 
struct GNUNET_RECLAIM_Attributeparse_jwt (const struct GNUNET_RECLAIM_Credential *cred, const char *claim)
 Parse a JWT and return the respective claim value as Attribute. More...
 
static void attr_collect (void *cls, const struct GNUNET_CRYPTO_PublicKey *identity, const struct GNUNET_RECLAIM_Attribute *attr)
 Collect all attributes for an ego. More...
 
static void list_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
 List attributes for identity request. More...
 
static void delete_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
 List attributes for identity request. More...
 
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)
 
static void consume_ticket_cont (struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
 
static void options_cont (struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
 Respond to OPTIONS request. More...
 
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. More...
 
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. More...
 
void * REST_reclaim_init (struct GNUNET_CONFIGURATION_Handle *c)
 Entry point for the plugin. More...
 
void * REST_reclaim_done (struct GNUNET_REST_Plugin *api)
 Exit point from the plugin. More...
 

Variables

const struct GNUNET_CONFIGURATION_Handlercfg
 The configuration handle. More...
 
static char * allow_methods
 HTTP methods allows for this plugin. More...
 
static struct EgoEntryego_head
 Ego list. More...
 
static struct EgoEntryego_tail
 Ego list. More...
 
static int state
 The processing state. More...
 
static struct GNUNET_IDENTITY_Handleidentity_handle
 Handle to Identity service. More...
 
static struct GNUNET_RECLAIM_Handleidp
 Identity Provider. More...
 
static struct RequestHandlerequests_head
 DLL. More...
 
static struct RequestHandlerequests_tail
 DLL. More...
 

Macro Definition Documentation

◆ GNUNET_REST_API_NS_RECLAIM

#define GNUNET_REST_API_NS_RECLAIM   "/reclaim"

REST root namespace.

Definition at line 43 of file reclaim_plugin.c.

◆ GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES

#define GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES   "/reclaim/attributes"

Attribute namespace.

Definition at line 48 of file reclaim_plugin.c.

◆ GNUNET_REST_API_NS_RECLAIM_CREDENTIAL

#define GNUNET_REST_API_NS_RECLAIM_CREDENTIAL   "/reclaim/credential"

Credential namespace.

Definition at line 53 of file reclaim_plugin.c.

◆ GNUNET_REST_API_NS_IDENTITY_TICKETS

#define GNUNET_REST_API_NS_IDENTITY_TICKETS   "/reclaim/tickets"

Ticket namespace.

Definition at line 58 of file reclaim_plugin.c.

◆ GNUNET_REST_API_NS_IDENTITY_REVOKE

#define GNUNET_REST_API_NS_IDENTITY_REVOKE   "/reclaim/revoke"

Revoke namespace.

Definition at line 63 of file reclaim_plugin.c.

◆ GNUNET_REST_API_NS_IDENTITY_CONSUME

#define GNUNET_REST_API_NS_IDENTITY_CONSUME   "/reclaim/consume"

Revoke namespace.

Definition at line 68 of file reclaim_plugin.c.

◆ ID_REST_STATE_INIT

#define ID_REST_STATE_INIT   0

State while collecting all egos.

Definition at line 73 of file reclaim_plugin.c.

◆ ID_REST_STATE_POST_INIT

#define ID_REST_STATE_POST_INIT   1

Done collecting egos.

Definition at line 78 of file reclaim_plugin.c.

Function Documentation

◆ cleanup_handle()

static void cleanup_handle ( void *  cls)
static

Cleanup lookup handle.

Parameters
handleHandle to clean up

Definition at line 274 of file reclaim_plugin.c.

275{
276 struct RequestHandle *handle = cls;
277
278 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n");
279 if (NULL != handle->resp_object)
280 json_decref (handle->resp_object);
281 if (NULL != handle->timeout_task)
282 GNUNET_SCHEDULER_cancel (handle->timeout_task);
283 if (NULL != handle->attr_it)
285 if (NULL != handle->cred_it)
287 if (NULL != handle->ticket_it)
289 if (NULL != handle->url)
290 GNUNET_free (handle->url);
291 if (NULL != handle->emsg)
292 GNUNET_free (handle->emsg);
293 if (NULL != handle->attr_list)
297 handle);
299}
static struct GNUNET_VPN_Handle * handle
Handle to vpn service.
Definition: gnunet-vpn.c:35
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_log(kind,...)
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_RECLAIM_attribute_list_destroy(struct GNUNET_RECLAIM_AttributeList *attrs)
Destroy claim list.
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_stop(struct GNUNET_RECLAIM_CredentialIterator *ait)
Stops iteration and releases the handle for further calls.
Definition: reclaim_api.c:1477
void GNUNET_RECLAIM_ticket_iteration_stop(struct GNUNET_RECLAIM_TicketIterator *it)
Stops iteration and releases the handle for further calls.
Definition: reclaim_api.c:1653
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:981
static struct RequestHandle * requests_head
DLL.
static struct RequestHandle * requests_tail
DLL.
The request handle.
Definition: config_plugin.c:46

References GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_RECLAIM_attribute_list_destroy(), GNUNET_RECLAIM_get_attributes_stop(), GNUNET_RECLAIM_get_credentials_stop(), GNUNET_RECLAIM_ticket_iteration_stop(), GNUNET_SCHEDULER_cancel(), handle, requests_head, and requests_tail.

Referenced by delete_finished_cb(), do_error(), finished_cont(), options_cont(), REST_reclaim_process_request(), and return_response().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ do_error()

static void do_error ( void *  cls)
static

Task run on error, sends error message.

Cleans up everything.

Parameters
clsthe struct RequestHandle

Definition at line 308 of file reclaim_plugin.c.

309{
310 struct RequestHandle *handle = cls;
311 struct MHD_Response *resp;
312 char *json_error;
313
314 GNUNET_asprintf (&json_error, "{ \"error\" : \"%s\" }", handle->emsg);
315 if (0 == handle->response_code)
316 {
317 handle->response_code = MHD_HTTP_BAD_REQUEST;
318 }
319 resp = GNUNET_REST_create_response (json_error);
320 GNUNET_assert (MHD_NO != MHD_add_response_header (resp, "Content-Type",
321 "application/json"));
322 handle->proc (handle->proc_cls, resp, handle->response_code);
324 GNUNET_free (json_error);
325}
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
struct MHD_Response * GNUNET_REST_create_response(const char *data)
Create REST MHD response.
Definition: rest.c:44
@ MHD_HTTP_BAD_REQUEST
Bad Request [RFC7231, Section 6.5.1].
static void cleanup_handle(void *cls)
Cleanup lookup handle.

References cleanup_handle(), GNUNET_asprintf(), GNUNET_assert, GNUNET_free, GNUNET_REST_create_response(), handle, and MHD_HTTP_BAD_REQUEST.

Referenced by add_attribute_cont(), add_credential_cont(), collect_error_cb(), consume_ticket_cont(), delete_attribute_cont(), delete_credential_cont(), delete_finished_cb(), do_timeout(), finished_cont(), list_attribute_cont(), list_credential_cont(), list_tickets_cont(), REST_reclaim_done(), and revoke_ticket_cont().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ do_timeout()

static void do_timeout ( void *  cls)
static

Task run on timeout, sends error message.

Cleans up everything.

Parameters
clsthe struct RequestHandle

Definition at line 334 of file reclaim_plugin.c.

335{
336 struct RequestHandle *handle = cls;
337
338 handle->timeout_task = NULL;
340}
static void do_error(void *cls)
Task run on error, sends error message.

References do_error(), and handle.

Referenced by REST_reclaim_process_request().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ collect_error_cb()

static void collect_error_cb ( void *  cls)
static

Definition at line 344 of file reclaim_plugin.c.

345{
347}
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

References do_error(), and GNUNET_SCHEDULER_add_now().

Referenced by list_attribute_cont(), list_credential_cont(), and list_tickets_cont().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ finished_cont()

static void finished_cont ( void *  cls,
int32_t  success,
const char *  emsg 
)
static

Definition at line 351 of file reclaim_plugin.c.

352{
353 struct RequestHandle *handle = cls;
354 struct MHD_Response *resp;
355
356 handle->idp_op = NULL;
357 if (GNUNET_OK != success)
358 {
360 return;
361 }
362 resp = GNUNET_REST_create_response (emsg);
363 GNUNET_assert (MHD_NO != MHD_add_response_header (resp,
364 "Content-Type",
365 "application/json"));
366 GNUNET_assert (MHD_NO != MHD_add_response_header (resp,
367 "Access-Control-Allow-Methods",
369 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
371}
@ GNUNET_OK
@ MHD_HTTP_OK
OK [RFC7231, Section 6.3.1].
static char * allow_methods
HTTP methods allows for this plugin.

References allow_methods, cleanup_handle(), do_error(), GNUNET_assert, GNUNET_OK, GNUNET_REST_create_response(), GNUNET_SCHEDULER_add_now(), handle, and MHD_HTTP_OK.

Referenced by add_attribute_cont(), add_credential_cont(), and revoke_ticket_cont().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ delete_finished_cb()

static void delete_finished_cb ( void *  cls,
int32_t  success,
const char *  emsg 
)
static

Definition at line 375 of file reclaim_plugin.c.

376{
377 struct RequestHandle *handle = cls;
378 struct MHD_Response *resp;
379
380 if (GNUNET_OK != success)
381 {
383 return;
384 }
385 resp = GNUNET_REST_create_response (emsg);
386 GNUNET_assert (MHD_NO != MHD_add_response_header (resp,
387 "Access-Control-Allow-Methods",
389 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
391}

References allow_methods, cleanup_handle(), do_error(), GNUNET_assert, GNUNET_OK, GNUNET_REST_create_response(), GNUNET_SCHEDULER_add_now(), handle, and MHD_HTTP_OK.

Referenced by delete_attribute_cont(), and delete_credential_cont().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ return_response()

static void return_response ( void *  cls)
static

Return attributes for identity.

Parameters
clsthe request handle

Definition at line 400 of file reclaim_plugin.c.

401{
402 char *result_str;
403 struct RequestHandle *handle = cls;
404 struct MHD_Response *resp;
405
406 result_str = json_dumps (handle->resp_object, 0);
407 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str);
408 resp = GNUNET_REST_create_response (result_str);
409 GNUNET_assert (MHD_NO !=
410 MHD_add_response_header (resp,
411 "Access-Control-Allow-Methods",
413 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
414 GNUNET_free (result_str);
416}

References allow_methods, cleanup_handle(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_REST_create_response(), handle, and MHD_HTTP_OK.

Referenced by collect_finished_cb(), consume_cont(), delete_attribute_cont(), delete_credential_cont(), list_attribute_cont(), list_credential_cont(), and list_tickets_cont().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ collect_finished_cb()

static void collect_finished_cb ( void *  cls)
static

Definition at line 420 of file reclaim_plugin.c.

421{
422 struct RequestHandle *handle = cls;
423
424 // Done
425 handle->attr_it = NULL;
426 handle->cred_it = NULL;
427 handle->ticket_it = NULL;
429}
static void return_response(void *cls)
Return attributes for identity.

References GNUNET_SCHEDULER_add_now(), handle, and return_response().

Referenced by list_attribute_cont(), list_credential_cont(), and list_tickets_cont().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ticket_collect()

static void ticket_collect ( void *  cls,
const struct GNUNET_RECLAIM_Ticket ticket,
const char *  rp_uri 
)
static

Collect all attributes for an ego.

Definition at line 437 of file reclaim_plugin.c.

439{
440 json_t *json_resource;
441 struct RequestHandle *handle = cls;
442
443 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding ticket\n");
444 json_resource = json_object ();
445 json_array_append (handle->resp_object, json_resource);
446
447 json_object_set_new (json_resource, "gns_name", json_string (ticket->gns_name)
448 );
449 json_object_set_new (json_resource, "rp_uri", json_string (rp_uri));
451}
static struct GNUNET_RECLAIM_Ticket ticket
Ticket to consume.
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:1633
char gns_name[63 *2+2]
The ticket.

References GNUNET_RECLAIM_Ticket::gns_name, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_RECLAIM_ticket_iteration_next(), handle, and ticket.

Referenced by list_tickets_cont().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_credential_cont()

static void add_credential_cont ( struct GNUNET_REST_RequestHandle con_handle,
const char *  url,
void *  cls 
)
static

New ID for attribute

Definition at line 455 of file reclaim_plugin.c.

458{
459 struct RequestHandle *handle = cls;
460 const struct GNUNET_CRYPTO_PrivateKey *identity_priv;
461 const char *identity;
462 struct EgoEntry *ego_entry;
463 struct GNUNET_RECLAIM_Credential *attribute;
464 struct GNUNET_TIME_Relative exp;
465 char term_data[handle->rest_handle->data_size + 1];
466 json_t *data_json;
467 json_error_t err;
468 struct GNUNET_JSON_Specification attrspec[] =
471
473 "Adding an credential for %s.\n",
474 handle->url);
475 if (strlen (GNUNET_REST_API_NS_RECLAIM_CREDENTIAL) >= strlen (
476 handle->url))
477 {
478 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
480 return;
481 }
482 identity = handle->url + strlen (
484
485 for (ego_entry = ego_head; NULL != ego_entry;
486 ego_entry = ego_entry->next)
487 if (0 == strcmp (identity, ego_entry->identifier))
488 break;
489
490 if (NULL == ego_entry)
491 {
492 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Identity unknown (%s)\n", identity);
493 return;
494 }
495 identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
496
497 if (0 >= handle->rest_handle->data_size)
498 {
500 return;
501 }
502
503 term_data[handle->rest_handle->data_size] = '\0';
504 GNUNET_memcpy (term_data,
505 handle->rest_handle->data,
506 handle->rest_handle->data_size);
507 data_json = json_loads (term_data, JSON_DECODE_ANY, &err);
508 if (GNUNET_OK != GNUNET_JSON_parse (data_json, attrspec, NULL, NULL))
509 {
510 json_decref (data_json);
512 "Unable to parse JSON from %s\n",
513 term_data);
515 return;
516 }
517 json_decref (data_json);
518 if (NULL == attribute)
519 {
521 "Unable to parse credential from %s\n",
522 term_data);
524 return;
525 }
529 if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&attribute->id))
530 GNUNET_RECLAIM_id_generate (&attribute->id);
533 identity_priv,
534 attribute,
535 &exp,
537 handle);
538 GNUNET_JSON_parse_free (attrspec);
539}
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
void GNUNET_JSON_parse_free(struct GNUNET_JSON_Specification *spec)
Frees all elements allocated during a GNUNET_JSON_parse() operation.
Definition: json.c:94
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
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
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_YES
@ GNUNET_ERROR_TYPE_ERROR
#define GNUNET_RECLAIM_id_is_zero(a)
#define GNUNET_RECLAIM_id_generate(id)
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
#define GNUNET_TIME_UNIT_HOURS
One hour.
struct GNUNET_JSON_Specification GNUNET_RECLAIM_JSON_spec_credential(struct GNUNET_RECLAIM_Credential **cred)
JSON Specification for credential claims.
Definition: json_reclaim.c:354
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 struct EgoEntry * ego_head
Ego list.
The default namestore ego.
char * identifier
Ego Identifier.
struct EgoEntry * next
DLL.
struct GNUNET_IDENTITY_Ego * ego
The Ego.
A private key for an identity as per LSD0001.
Entry in parser specification for GNUNET_JSON_parse().
struct GNUNET_RECLAIM_Identifier id
ID.
Time for relative time used by GNUnet, in microseconds.

References do_error(), EgoEntry::ego, ego_head, finished_cont(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_IDENTITY_ego_get_private_key(), GNUNET_JSON_parse(), GNUNET_JSON_parse_free(), GNUNET_JSON_spec_end(), GNUNET_log, GNUNET_memcpy, GNUNET_OK, GNUNET_RECLAIM_credential_store(), GNUNET_RECLAIM_id_generate, GNUNET_RECLAIM_id_is_zero, GNUNET_RECLAIM_JSON_spec_credential(), GNUNET_REST_API_NS_RECLAIM_CREDENTIAL, GNUNET_SCHEDULER_add_now(), GNUNET_TIME_UNIT_HOURS, GNUNET_YES, handle, GNUNET_RECLAIM_Credential::id, EgoEntry::identifier, identity, idp, and EgoEntry::next.

Referenced by REST_reclaim_process_request().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cred_collect()

static void cred_collect ( void *  cls,
const struct GNUNET_CRYPTO_PublicKey identity,
const struct GNUNET_RECLAIM_Credential cred 
)
static

Collect all credentials for an ego.

Definition at line 547 of file reclaim_plugin.c.

550{
551 struct RequestHandle *handle = cls;
552 struct GNUNET_RECLAIM_AttributeList *attrs;
554 struct GNUNET_TIME_Absolute exp;
555 json_t *attr_obj;
556 json_t *cred_obj;
557 const char *type;
558 char *tmp_value;
559 char *id_str;
560 char *issuer;
561
562
563 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding credential: %s\n",
564 cred->name);
568 cred->data,
569 cred->data_size);
570 cred_obj = json_object ();
571 json_object_set_new (cred_obj, "value", json_string (tmp_value));
572 json_object_set_new (cred_obj, "name", json_string (cred->name));
574 json_object_set_new (cred_obj, "type", json_string (type));
575 if (NULL != issuer)
576 {
577 json_object_set_new (cred_obj, "issuer", json_string (issuer));
578 GNUNET_free (issuer);
579 }
581 &exp))
582 {
583 json_object_set_new (cred_obj, "expiration", json_integer (
584 exp.abs_value_us));
585 }
587 sizeof(cred->id));
588 json_object_set_new (cred_obj, "id", json_string (id_str));
589 GNUNET_free (tmp_value);
590 GNUNET_free (id_str);
591 if (NULL != attrs)
592 {
593 json_t *attr_arr = json_array ();
594 for (ale = attrs->list_head; NULL != ale; ale = ale->next)
595 {
596 tmp_value =
598 ale->attribute->data,
599 ale->attribute->data_size);
600 attr_obj = json_object ();
601 json_object_set_new (attr_obj, "value", json_string (tmp_value));
602 json_object_set_new (attr_obj, "name", json_string (
603 ale->attribute->name));
604
605 json_object_set_new (attr_obj, "flag", json_string ("1")); // FIXME
607 json_object_set_new (attr_obj, "type", json_string (type));
608 json_object_set_new (attr_obj, "id", json_string (""));
609 json_object_set_new (attr_obj, "credential", json_string (""));
610 json_array_append_new (attr_arr, attr_obj);
611 GNUNET_free (tmp_value);
612 }
613 json_object_set_new (cred_obj, "attributes", attr_arr);
614 }
615 json_array_append_new (handle->resp_object, cred_obj);
616 if (NULL != attrs)
619}
static uint32_t type
Type string converted to DNS type value.
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.
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.
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_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
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
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.
uint32_t type
Type of Claim.
const void * data
Binary value stored as attribute value.
size_t data_size
Number of bytes in data.
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.
Time for absolute times used by GNUnet, in microseconds.

References GNUNET_TIME_Absolute::abs_value_us, GNUNET_RECLAIM_AttributeListEntry::attribute, GNUNET_RECLAIM_Attribute::data, GNUNET_RECLAIM_Credential::data, GNUNET_RECLAIM_Attribute::data_size, GNUNET_RECLAIM_Credential::data_size, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_OK, GNUNET_RECLAIM_attribute_list_destroy(), GNUNET_RECLAIM_attribute_number_to_typename(), GNUNET_RECLAIM_attribute_value_to_string(), GNUNET_RECLAIM_credential_get_attributes(), GNUNET_RECLAIM_credential_get_expiration(), GNUNET_RECLAIM_credential_get_issuer(), GNUNET_RECLAIM_credential_number_to_typename(), GNUNET_RECLAIM_credential_value_to_string(), GNUNET_RECLAIM_get_credentials_next(), GNUNET_STRINGS_data_to_string_alloc(), handle, GNUNET_RECLAIM_Credential::id, GNUNET_RECLAIM_AttributeList::list_head, GNUNET_RECLAIM_Attribute::name, GNUNET_RECLAIM_Credential::name, GNUNET_RECLAIM_AttributeListEntry::next, type, GNUNET_RECLAIM_Attribute::type, and GNUNET_RECLAIM_Credential::type.

Referenced by list_credential_cont().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ list_credential_cont()

static void list_credential_cont ( struct GNUNET_REST_RequestHandle con_handle,
const char *  url,
void *  cls 
)
static

Lists credential for identity request.

Parameters
con_handlethe connection handle
urlthe url
clsthe RequestHandle

Definition at line 630 of file reclaim_plugin.c.

633{
634 struct RequestHandle *handle = cls;
635 const struct GNUNET_CRYPTO_PrivateKey *priv_key;
636 struct EgoEntry *ego_entry;
637 char *identity;
638
640 "Getting credentials for %s.\n",
641 handle->url);
642 if (strlen (GNUNET_REST_API_NS_RECLAIM_CREDENTIAL) >= strlen (
643 handle->url))
644 {
645 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
647 return;
648 }
649 identity = handle->url + strlen (
651
652 for (ego_entry = ego_head; NULL != ego_entry;
653 ego_entry = ego_entry->next)
654 if (0 == strcmp (identity, ego_entry->identifier))
655 break;
656 handle->resp_object = json_array ();
657
658
659 if (NULL == ego_entry)
660 {
661 // Done
662 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
664 return;
665 }
666 priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
668 priv_key,
670 handle,
672 handle,
673 &
675 handle);
676}
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
static void collect_error_cb(void *cls)
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 collect_finished_cb(void *cls)

References collect_error_cb(), collect_finished_cb(), cred_collect(), do_error(), EgoEntry::ego, ego_head, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_IDENTITY_ego_get_private_key(), GNUNET_log, GNUNET_RECLAIM_get_credentials_start(), GNUNET_REST_API_NS_RECLAIM_CREDENTIAL, GNUNET_SCHEDULER_add_now(), handle, EgoEntry::identifier, identity, idp, EgoEntry::next, and return_response().

Referenced by REST_reclaim_process_request().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ delete_credential_cont()

static void delete_credential_cont ( struct GNUNET_REST_RequestHandle con_handle,
const char *  url,
void *  cls 
)
static

Deletes credential from an identity.

Parameters
con_handlethe connection handle
urlthe url
clsthe RequestHandle

Definition at line 687 of file reclaim_plugin.c.

690{
691 struct RequestHandle *handle = cls;
692 const struct GNUNET_CRYPTO_PrivateKey *priv_key;
693 struct GNUNET_RECLAIM_Credential attr;
694 struct EgoEntry *ego_entry;
695 char *identity_id_str;
696 char *identity;
697 char *id;
698
699 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting credential.\n");
700 if (strlen (GNUNET_REST_API_NS_RECLAIM_CREDENTIAL) >= strlen (
701 handle->url))
702 {
703 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
705 return;
706 }
707 identity_id_str =
708 strdup (handle->url + strlen (
710 identity = strtok (identity_id_str, "/");
711 id = strtok (NULL, "/");
712 if ((NULL == identity) || (NULL == id))
713 {
714 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Malformed request.\n");
715 GNUNET_free (identity_id_str);
717 return;
718 }
719
720 for (ego_entry = ego_head; NULL != ego_entry;
721 ego_entry = ego_entry->next)
722 if (0 == strcmp (identity, ego_entry->identifier))
723 break;
724 handle->resp_object = json_array ();
725 if (NULL == ego_entry)
726 {
727 // Done
728 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
729 GNUNET_free (identity_id_str);
731 return;
732 }
733 priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
734 memset (&attr, 0, sizeof(struct GNUNET_RECLAIM_Credential));
735 GNUNET_STRINGS_string_to_data (id, strlen (id), &attr.id, sizeof(attr.id));
736 attr.name = "";
738 priv_key,
739 &attr,
741 handle);
742 GNUNET_free (identity_id_str);
743}
static struct GNUNET_IDENTITY_Handle * id
Handle to IDENTITY.
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
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
static void delete_finished_cb(void *cls, int32_t success, const char *emsg)

References delete_finished_cb(), do_error(), EgoEntry::ego, ego_head, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_IDENTITY_ego_get_private_key(), GNUNET_log, GNUNET_RECLAIM_credential_delete(), GNUNET_REST_API_NS_RECLAIM_CREDENTIAL, GNUNET_SCHEDULER_add_now(), GNUNET_STRINGS_string_to_data(), handle, id, GNUNET_RECLAIM_Credential::id, EgoEntry::identifier, identity, idp, GNUNET_RECLAIM_Credential::name, EgoEntry::next, and return_response().

Referenced by REST_reclaim_process_request().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ list_tickets_cont()

static void list_tickets_cont ( struct GNUNET_REST_RequestHandle con_handle,
const char *  url,
void *  cls 
)
static

List tickets for identity request.

Parameters
con_handlethe connection handle
urlthe url
clsthe RequestHandle

Definition at line 754 of file reclaim_plugin.c.

757{
758 const struct GNUNET_CRYPTO_PrivateKey *priv_key;
759 struct RequestHandle *handle = cls;
760 struct EgoEntry *ego_entry;
761 char *identity;
762
764 "Getting tickets for %s.\n",
765 handle->url);
766 if (strlen (GNUNET_REST_API_NS_IDENTITY_TICKETS) >= strlen (handle->url))
767 {
768 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
770 return;
771 }
773
774 for (ego_entry = ego_head; NULL != ego_entry;
775 ego_entry = ego_entry->next)
776 if (0 == strcmp (identity, ego_entry->identifier))
777 break;
778 handle->resp_object = json_array ();
779
780 if (NULL == ego_entry)
781 {
782 // Done
783 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
785 return;
786 }
787 priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
788 handle->ticket_it =
790 priv_key,
792 handle,
794 handle,
796 handle);
797}
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 identites (relying parties)
Definition: reclaim_api.c:1580
#define GNUNET_REST_API_NS_IDENTITY_TICKETS
Ticket namespace.
static void ticket_collect(void *cls, const struct GNUNET_RECLAIM_Ticket *ticket, const char *rp_uri)
Collect all attributes for an ego.

References collect_error_cb(), collect_finished_cb(), do_error(), EgoEntry::ego, ego_head, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_IDENTITY_ego_get_private_key(), GNUNET_log, GNUNET_RECLAIM_ticket_iteration_start(), GNUNET_REST_API_NS_IDENTITY_TICKETS, GNUNET_SCHEDULER_add_now(), handle, EgoEntry::identifier, identity, idp, EgoEntry::next, return_response(), and ticket_collect().

Referenced by REST_reclaim_process_request().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_attribute_cont()

static void add_attribute_cont ( struct GNUNET_REST_RequestHandle con_handle,
const char *  url,
void *  cls 
)
static

New ID for attribute

Definition at line 801 of file reclaim_plugin.c.

804{
805 const struct GNUNET_CRYPTO_PrivateKey *identity_priv;
806 const char *identity;
807 struct RequestHandle *handle = cls;
808 struct EgoEntry *ego_entry;
809 struct GNUNET_RECLAIM_Attribute *attribute;
810 struct GNUNET_TIME_Relative exp;
811 char term_data[handle->rest_handle->data_size + 1];
812 json_t *data_json;
813 json_error_t err;
814 struct GNUNET_JSON_Specification attrspec[] =
816
818 "Adding an attribute for %s.\n",
819 handle->url);
820 if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) >= strlen (handle->url))
821 {
822 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
824 return;
825 }
827
828 for (ego_entry = ego_head; NULL != ego_entry;
829 ego_entry = ego_entry->next)
830 if (0 == strcmp (identity, ego_entry->identifier))
831 break;
832
833 if (NULL == ego_entry)
834 {
835 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Identity unknown (%s)\n", identity);
836 return;
837 }
838 identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
839
840 if (0 >= handle->rest_handle->data_size)
841 {
843 return;
844 }
845
846 term_data[handle->rest_handle->data_size] = '\0';
847 GNUNET_memcpy (term_data,
848 handle->rest_handle->data,
849 handle->rest_handle->data_size);
850 data_json = json_loads (term_data, JSON_DECODE_ANY, &err);
852 GNUNET_JSON_parse (data_json, attrspec, NULL, NULL));
853 json_decref (data_json);
854 if (NULL == attribute)
855 {
857 "Unable to parse attribute from %s\n",
858 term_data);
860 return;
861 }
865 if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&attribute->id))
866 GNUNET_RECLAIM_id_generate (&attribute->id);
869 identity_priv,
870 attribute,
871 &exp,
873 handle);
874 GNUNET_JSON_parse_free (attrspec);
875}
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_JSON_Specification GNUNET_RECLAIM_JSON_spec_attribute(struct GNUNET_RECLAIM_Attribute **attr)
JSON Specification for Reclaim claims.
Definition: json_reclaim.c:146
#define GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES
Attribute namespace.
struct GNUNET_RECLAIM_Identifier id
ID.

References do_error(), EgoEntry::ego, ego_head, finished_cont(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_IDENTITY_ego_get_private_key(), GNUNET_JSON_parse(), GNUNET_JSON_parse_free(), GNUNET_JSON_spec_end(), GNUNET_log, GNUNET_memcpy, GNUNET_OK, GNUNET_RECLAIM_attribute_store(), GNUNET_RECLAIM_id_generate, GNUNET_RECLAIM_id_is_zero, GNUNET_RECLAIM_JSON_spec_attribute(), GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, GNUNET_SCHEDULER_add_now(), GNUNET_TIME_UNIT_HOURS, GNUNET_YES, handle, GNUNET_RECLAIM_Attribute::id, EgoEntry::identifier, identity, idp, and EgoEntry::next.

Referenced by REST_reclaim_process_request().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_jwt()

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.

Parameters
credthe jwt credential
claimthe name of the claim in the JWT
Returns
a GNUNET_RECLAIM_Attribute, containing the new value

Definition at line 887 of file reclaim_plugin.c.

889{
890 char *jwt_string;
891 struct GNUNET_RECLAIM_Attribute *attr;
892 char delim[] = ".";
893 const char *type_str = NULL;
894 const char *val_str = NULL;
895 char *data;
896 size_t data_size;
897 uint32_t type;
898 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Parsing JWT attributes.\n");
899 char *decoded_jwt;
900 json_t *json_val;
901 json_error_t *json_err = NULL;
902
904 cred->data,
905 cred->data_size);
906 char *jwt_body = strtok (jwt_string, delim);
907 jwt_body = strtok (NULL, delim);
908 GNUNET_STRINGS_base64_decode (jwt_body, strlen (jwt_body),
909 (void **) &decoded_jwt);
910 json_val = json_loads (decoded_jwt, JSON_DECODE_ANY, json_err);
911 const char *key;
912 json_t *value;
913 json_object_foreach (json_val, key, value) {
914 if (0 == strcasecmp (key,claim))
915 {
916 val_str = json_dumps (value, JSON_ENCODE_ANY);
917 }
918 }
919 type_str = "String";
922 (void **) &data
923 ,
924 &data_size))
925 {
927 "Attribute value from JWT Parser invalid!\n");
929 "Error: Referenced Claim Name not Found",
930 (void **) &data,
931 &data_size);
932 attr = GNUNET_RECLAIM_attribute_new (claim, &cred->id,
934 attr->id = cred->id;
935 attr->flag = 1;
936 }
937 else
938 {
939 attr = GNUNET_RECLAIM_attribute_new (claim, &cred->id,
941 attr->id = cred->id;
942 attr->flag = 1;
943 }
944 return attr;
945}
static char * data
The data to insert into the dht.
struct GNUNET_HashCode key
The key used in the DHT.
static char * value
Value of the record to add/remove.
static size_t data_size
Number of bytes in data.
struct GNUNET_RECLAIM_Attribute * claim
Claim to store.
static char * type_str
Attribute type.
@ GNUNET_SYSERR
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.
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.
uint32_t GNUNET_RECLAIM_attribute_typename_to_number(const char *typename)
Convert a type name to the corresponding number.
size_t GNUNET_STRINGS_base64_decode(const char *data, size_t len, void **output)
Decode from Base64.
Definition: strings.c:1724

References claim, data, GNUNET_RECLAIM_Credential::data, data_size, GNUNET_RECLAIM_Credential::data_size, GNUNET_RECLAIM_Attribute::flag, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_RECLAIM_attribute_new(), GNUNET_RECLAIM_attribute_string_to_value(), GNUNET_RECLAIM_attribute_typename_to_number(), GNUNET_RECLAIM_credential_value_to_string(), GNUNET_STRINGS_base64_decode(), GNUNET_SYSERR, GNUNET_RECLAIM_Attribute::id, GNUNET_RECLAIM_Credential::id, key, type, GNUNET_RECLAIM_Credential::type, type_str, and value.

Here is the call graph for this function:

◆ attr_collect()

static void attr_collect ( void *  cls,
const struct GNUNET_CRYPTO_PublicKey identity,
const struct GNUNET_RECLAIM_Attribute attr 
)
static

Collect all attributes for an ego.

Definition at line 953 of file reclaim_plugin.c.

956{
957 struct RequestHandle *handle = cls;
958 json_t *attr_obj;
959 const char *type;
960 char *id_str;
961
962 char *tmp_value;
964 attr->data,
965 attr->data_size);
966 attr_obj = json_object ();
967 json_object_set_new (attr_obj, "value", json_string (tmp_value));
968 json_object_set_new (attr_obj, "name", json_string (attr->name));
969
971 json_object_set_new (attr_obj, "flag", json_string ("0"));
972 else
973 json_object_set_new (attr_obj, "flag", json_string ("1"));
975 json_object_set_new (attr_obj, "type", json_string (type));
977 sizeof(attr->id));
978 json_object_set_new (attr_obj, "id", json_string (id_str));
979 GNUNET_free (id_str);
981 sizeof(attr->credential));
982 json_object_set_new (attr_obj, "credential", json_string (id_str));
983 GNUNET_free (id_str);
984 json_array_append (handle->resp_object, attr_obj);
985 json_decref (attr_obj);
986 GNUNET_free (tmp_value);
988}
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_Identifier credential
Referenced ID of credential (may be GNUNET_RECLAIM_ID_ZERO if self-creded)

References GNUNET_RECLAIM_Attribute::credential, GNUNET_RECLAIM_Attribute::data, GNUNET_RECLAIM_Attribute::data_size, GNUNET_free, GNUNET_RECLAIM_attribute_number_to_typename(), GNUNET_RECLAIM_attribute_value_to_string(), GNUNET_RECLAIM_get_attributes_next(), GNUNET_RECLAIM_id_is_zero, GNUNET_STRINGS_data_to_string_alloc(), handle, GNUNET_RECLAIM_Attribute::id, GNUNET_RECLAIM_Attribute::name, type, and GNUNET_RECLAIM_Attribute::type.

Referenced by list_attribute_cont().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ list_attribute_cont()

static void list_attribute_cont ( struct GNUNET_REST_RequestHandle con_handle,
const char *  url,
void *  cls 
)
static

List attributes for identity request.

Parameters
con_handlethe connection handle
urlthe url
clsthe RequestHandle

Definition at line 999 of file reclaim_plugin.c.

1002{
1003 const struct GNUNET_CRYPTO_PrivateKey *priv_key;
1004 struct RequestHandle *handle = cls;
1005 struct EgoEntry *ego_entry;
1006 char *identity;
1007
1009 "Getting attributes for %s.\n",
1010 handle->url);
1011 if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) >= strlen (handle->url))
1012 {
1013 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
1015 return;
1016 }
1018
1019 for (ego_entry = ego_head; NULL != ego_entry;
1020 ego_entry = ego_entry->next)
1021 if (0 == strcmp (identity, ego_entry->identifier))
1022 break;
1023 handle->resp_object = json_array ();
1024
1025
1026 if (NULL == ego_entry)
1027 {
1028 // Done
1029 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
1031 return;
1032 }
1033 priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
1035 priv_key,
1037 handle,
1038 &attr_collect,
1039 handle,
1041 handle);
1042}
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
static void attr_collect(void *cls, const struct GNUNET_CRYPTO_PublicKey *identity, const struct GNUNET_RECLAIM_Attribute *attr)
Collect all attributes for an ego.

References attr_collect(), collect_error_cb(), collect_finished_cb(), do_error(), EgoEntry::ego, ego_head, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_IDENTITY_ego_get_private_key(), GNUNET_log, GNUNET_RECLAIM_get_attributes_start(), GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, GNUNET_SCHEDULER_add_now(), handle, EgoEntry::identifier, identity, idp, EgoEntry::next, and return_response().

Referenced by REST_reclaim_process_request().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ delete_attribute_cont()

static void delete_attribute_cont ( struct GNUNET_REST_RequestHandle con_handle,
const char *  url,
void *  cls 
)
static

List attributes for identity request.

Parameters
con_handlethe connection handle
urlthe url
clsthe RequestHandle

Definition at line 1053 of file reclaim_plugin.c.

1056{
1057 const struct GNUNET_CRYPTO_PrivateKey *priv_key;
1058 struct RequestHandle *handle = cls;
1059 struct GNUNET_RECLAIM_Attribute attr;
1060 struct EgoEntry *ego_entry;
1061 char *identity_id_str;
1062 char *identity;
1063 char *id;
1064
1065 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting attributes.\n");
1066 if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) >= strlen (handle->url))
1067 {
1068 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
1070 return;
1071 }
1072 identity_id_str =
1073 strdup (handle->url + strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) + 1);
1074 identity = strtok (identity_id_str, "/");
1075 id = strtok (NULL, "/");
1076 if ((NULL == identity) || (NULL == id))
1077 {
1078 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Malformed request.\n");
1079 GNUNET_free (identity_id_str);
1081 return;
1082 }
1083
1084 for (ego_entry = ego_head; NULL != ego_entry;
1085 ego_entry = ego_entry->next)
1086 if (0 == strcmp (identity, ego_entry->identifier))
1087 break;
1088 handle->resp_object = json_array ();
1089 if (NULL == ego_entry)
1090 {
1091 // Done
1092 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
1093 GNUNET_free (identity_id_str);
1095 return;
1096 }
1097 priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
1098 memset (&attr, 0, sizeof(struct GNUNET_RECLAIM_Attribute));
1099 GNUNET_STRINGS_string_to_data (id, strlen (id), &attr.id, sizeof(attr.id));
1100 attr.name = "";
1102 priv_key,
1103 &attr,
1105 handle);
1106 GNUNET_free (identity_id_str);
1107}
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

References delete_finished_cb(), do_error(), EgoEntry::ego, ego_head, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_IDENTITY_ego_get_private_key(), GNUNET_log, GNUNET_RECLAIM_attribute_delete(), GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, GNUNET_SCHEDULER_add_now(), GNUNET_STRINGS_string_to_data(), handle, id, GNUNET_RECLAIM_Attribute::id, EgoEntry::identifier, identity, idp, GNUNET_RECLAIM_Attribute::name, EgoEntry::next, and return_response().

Referenced by REST_reclaim_process_request().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ revoke_ticket_cont()

static void revoke_ticket_cont ( struct GNUNET_REST_RequestHandle con_handle,
const char *  url,
void *  cls 
)
static

Definition at line 1111 of file reclaim_plugin.c.

1114{
1115 const struct GNUNET_CRYPTO_PrivateKey *identity_priv;
1116 struct RequestHandle *handle = cls;
1117 struct EgoEntry *ego_entry;
1118 struct GNUNET_RECLAIM_Ticket *ticket = NULL;
1119 struct GNUNET_CRYPTO_PublicKey iss;
1120 struct GNUNET_CRYPTO_PublicKey tmp_pk;
1121 char term_data[handle->rest_handle->data_size + 1];
1122 json_t *data_json;
1123 json_error_t err;
1124 struct GNUNET_JSON_Specification tktspec[] =
1126
1127 if (0 >= handle->rest_handle->data_size)
1128 {
1130 return;
1131 }
1132
1133 term_data[handle->rest_handle->data_size] = '\0';
1134 GNUNET_memcpy (term_data,
1135 handle->rest_handle->data,
1136 handle->rest_handle->data_size);
1137 data_json = json_loads (term_data, JSON_DECODE_ANY, &err);
1138 if ((NULL == data_json) ||
1139 (GNUNET_OK != GNUNET_JSON_parse (data_json, tktspec, NULL, NULL)))
1140 {
1141 handle->emsg = GNUNET_strdup ("Not a ticket!\n");
1143 GNUNET_JSON_parse_free (tktspec);
1144 if (NULL != data_json)
1145 json_decref (data_json);
1146 return;
1147 }
1148 json_decref (data_json);
1149 if (NULL == ticket)
1150 {
1152 "Unable to parse ticket from %s\n",
1153 term_data);
1155 return;
1156 }
1157
1159
1160 for (ego_entry = ego_head; NULL != ego_entry;
1161 ego_entry = ego_entry->next)
1162 {
1163 GNUNET_IDENTITY_ego_get_public_key (ego_entry->ego, &tmp_pk);
1164 if (0 == memcmp (&iss,
1165 &tmp_pk,
1166 sizeof(struct GNUNET_CRYPTO_PublicKey)))
1167 break;
1168 }
1169 if (NULL == ego_entry)
1170 {
1171 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Identity unknown\n");
1172 GNUNET_JSON_parse_free (tktspec);
1173 return;
1174 }
1175 identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
1176
1178 identity_priv,
1179 ticket,
1181 handle);
1182 GNUNET_JSON_parse_free (tktspec);
1183}
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
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_strdup(a)
Wrapper around GNUNET_xstrdup_.
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:1684
struct GNUNET_JSON_Specification GNUNET_RECLAIM_JSON_spec_ticket(struct GNUNET_RECLAIM_Ticket **ticket)
JSON Specification for Reclaim tickets.
Definition: json_reclaim.c:230
An identity key as per LSD0001.
The authorization ticket.

References do_error(), EgoEntry::ego, ego_head, finished_cont(), GNUNET_RECLAIM_Ticket::gns_name, GNUNET_assert, GNUNET_ERROR_TYPE_ERROR, GNUNET_GNS_parse_ztld(), GNUNET_IDENTITY_ego_get_private_key(), GNUNET_IDENTITY_ego_get_public_key(), GNUNET_JSON_parse(), GNUNET_JSON_parse_free(), GNUNET_JSON_spec_end(), GNUNET_log, GNUNET_memcpy, GNUNET_OK, GNUNET_RECLAIM_JSON_spec_ticket(), GNUNET_RECLAIM_ticket_revoke(), GNUNET_SCHEDULER_add_now(), GNUNET_strdup, handle, idp, EgoEntry::next, and ticket.

Referenced by REST_reclaim_process_request().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ consume_cont()

static void consume_cont ( void *  cls,
const struct GNUNET_CRYPTO_PublicKey identity,
const struct GNUNET_RECLAIM_Attribute attr,
const struct GNUNET_RECLAIM_Presentation presentation 
)
static

Definition at line 1187 of file reclaim_plugin.c.

1191{
1192 struct RequestHandle *handle = cls;
1193 char *val_str;
1194 json_t *value;
1195
1196 if (NULL == identity)
1197 {
1199 return;
1200 }
1201
1202 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute: %s\n", attr->name);
1204 attr->data,
1205 attr->data_size);
1206 if (NULL == val_str)
1207 {
1209 "Failed to parse value for: %s\n",
1210 attr->name);
1211 return;
1212 }
1213 value = json_string (val_str);
1214 json_object_set_new (handle->resp_object, attr->name, value);
1215 json_decref (value);
1216 GNUNET_free (val_str);
1217}

References GNUNET_RECLAIM_Attribute::data, GNUNET_RECLAIM_Attribute::data_size, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_RECLAIM_attribute_value_to_string(), GNUNET_SCHEDULER_add_now(), handle, identity, GNUNET_RECLAIM_Attribute::name, return_response(), GNUNET_RECLAIM_Attribute::type, and value.

Referenced by consume_ticket_cont().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ consume_ticket_cont()

static void consume_ticket_cont ( struct GNUNET_REST_RequestHandle con_handle,
const char *  url,
void *  cls 
)
static

Definition at line 1221 of file reclaim_plugin.c.

1224{
1225 struct RequestHandle *handle = cls;
1227 char term_data[handle->rest_handle->data_size + 1];
1228 json_t *data_json;
1229 json_error_t err;
1230 struct GNUNET_JSON_Specification tktspec[] =
1232
1233 if (0 >= handle->rest_handle->data_size)
1234 {
1236 return;
1237 }
1238
1239 term_data[handle->rest_handle->data_size] = '\0';
1240 GNUNET_memcpy (term_data,
1241 handle->rest_handle->data,
1242 handle->rest_handle->data_size);
1243 data_json = json_loads (term_data, JSON_DECODE_ANY, &err);
1244 if (NULL == data_json)
1245 {
1247 "Unable to parse JSON Object from %s\n",
1248 term_data);
1250 return;
1251 }
1252 if (GNUNET_OK != GNUNET_JSON_parse (data_json, tktspec, NULL, NULL))
1253 {
1254 handle->emsg = GNUNET_strdup ("Not a ticket!\n");
1256 GNUNET_JSON_parse_free (tktspec);
1257 json_decref (data_json);
1258 return;
1259 }
1260 handle->resp_object = json_object ();
1262 ticket,
1263 &consume_cont,
1264 handle);
1265 GNUNET_JSON_parse_free (tktspec);
1266}
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_ticket_consume(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_RECLAIM_Ticket *ticket, GNUNET_RECLAIM_AttributeTicketResult cb, void *cb_cls)
Consumes an issued ticket.
Definition: reclaim_api.c:1546
static void consume_cont(void *cls, const struct GNUNET_CRYPTO_PublicKey *identity, const struct GNUNET_RECLAIM_Attribute *attr, const struct GNUNET_RECLAIM_Presentation *presentation)

References consume_cont(), do_error(), GNUNET_ERROR_TYPE_ERROR, GNUNET_JSON_parse(), GNUNET_JSON_parse_free(), GNUNET_JSON_spec_end(), GNUNET_log, GNUNET_memcpy, GNUNET_OK, GNUNET_RECLAIM_JSON_spec_ticket(), GNUNET_RECLAIM_ticket_consume(), GNUNET_SCHEDULER_add_now(), GNUNET_strdup, handle, idp, and ticket.

Referenced by REST_reclaim_process_request().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ options_cont()

static void options_cont ( struct GNUNET_REST_RequestHandle con_handle,
const char *  url,
void *  cls 
)
static

Respond to OPTIONS request.

Parameters
con_handlethe connection handle
urlthe url
clsthe RequestHandle

Definition at line 1277 of file reclaim_plugin.c.

1280{
1281 struct MHD_Response *resp;
1282 struct RequestHandle *handle = cls;
1283
1284 // For now, independent of path return all options
1285 resp = GNUNET_REST_create_response (NULL);
1286 GNUNET_assert (MHD_NO != MHD_add_response_header (resp,
1287 "Access-Control-Allow-Methods",
1288 allow_methods));
1289 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
1291 return;
1292}

References allow_methods, cleanup_handle(), GNUNET_assert, GNUNET_REST_create_response(), handle, and MHD_HTTP_OK.

Referenced by REST_reclaim_process_request().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ list_ego()

static void list_ego ( void *  cls,
struct GNUNET_IDENTITY_Ego ego,
void **  ctx,
const char *  identifier 
)
static

If listing is enabled, prints information about the egos.

This function is initially called for all egos and then again whenever a ego's identifier changes or if it is deleted. At the end of the initial pass over all egos, the function is once called with 'NULL' for 'ego'. That does NOT mean that the callback won't be invoked in the future or that there was an error.

When used with 'GNUNET_IDENTITY_create' or 'GNUNET_IDENTITY_get', this function is only called ONCE, and 'NULL' being passed in 'ego' does indicate an error (for example because name is taken or no default value is known). If 'ego' is non-NULL and if '*ctx' is set in those callbacks, the value WILL be passed to a subsequent call to the identity callback of 'GNUNET_IDENTITY_connect' (if that one was not NULL).

When an identity is renamed, this function is called with the (known) ego but the NEW identifier.

When an identity is deleted, this function is called with the (known) ego and "NULL" for the 'identifier'. In this case, the 'ego' is henceforth invalid (and the 'ctx' should also be cleaned up).

Parameters
clsclosure
egoego handle
ctxcontext for application to store data for this ego (during the lifetime of this process, initially NULL)
identifieridentifier assigned by the user for this ego, NULL if the user just deleted the ego and it must thus no longer be used

Definition at line 1328 of file reclaim_plugin.c.

1332{
1333 struct EgoEntry *ego_entry;
1335
1336 if (NULL == ego)
1337 {
1339 return;
1340 }
1342 {
1343 ego_entry = GNUNET_new (struct EgoEntry);
1346 ego_entry->ego = ego;
1347 ego_entry->identifier = GNUNET_strdup (identifier);
1349 ego_tail,
1350 ego_entry);
1351 }
1352 /* Ego renamed or added */
1353 if (identifier != NULL)
1354 {
1355 for (ego_entry = ego_head; NULL != ego_entry;
1356 ego_entry = ego_entry->next)
1357 {
1358 if (ego_entry->ego == ego)
1359 {
1360 /* Rename */
1361 GNUNET_free (ego_entry->identifier);
1362 ego_entry->identifier = GNUNET_strdup (identifier);
1363 break;
1364 }
1365 }
1366 if (NULL == ego_entry)
1367 {
1368 /* Add */
1369 ego_entry = GNUNET_new (struct EgoEntry);
1372 ego_entry->ego = ego;
1373 ego_entry->identifier = GNUNET_strdup (identifier);
1375 ego_tail,
1376 ego_entry);
1377 }
1378 }
1379 else
1380 {
1381 /* Delete */
1382 for (ego_entry = ego_head; NULL != ego_entry;
1383 ego_entry = ego_entry->next)
1384 {
1385 if (ego_entry->ego == ego)
1386 break;
1387 }
1388 if (NULL == ego_entry)
1389 return; /* Not found */
1390
1392 ego_tail,
1393 ego_entry);
1394 GNUNET_free (ego_entry->identifier);
1395 GNUNET_free (ego_entry->keystring);
1396 GNUNET_free (ego_entry);
1397 return;
1398 }
1399
1400}
struct GNUNET_CRYPTO_PrivateKey pk
Private key from command line option, or NULL.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
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:551
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static struct EgoEntry * ego_tail
Ego list.
#define ID_REST_STATE_INIT
State while collecting all egos.
static int state
The processing state.
#define ID_REST_STATE_POST_INIT
Done collecting egos.
char * keystring
Public key string.

References EgoEntry::ego, ego_head, ego_tail, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_CONTAINER_DLL_remove, GNUNET_CRYPTO_public_key_to_string(), GNUNET_free, GNUNET_IDENTITY_ego_get_public_key(), GNUNET_new, GNUNET_strdup, ID_REST_STATE_INIT, ID_REST_STATE_POST_INIT, EgoEntry::identifier, EgoEntry::keystring, EgoEntry::next, pk, and state.

Referenced by REST_reclaim_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ REST_reclaim_process_request()

enum GNUNET_GenericReturnValue REST_reclaim_process_request ( void *  plugin,
struct GNUNET_REST_RequestHandle conndata_handle,
GNUNET_REST_ResultProcessor  proc,
void *  proc_cls 
)

Function processing the REST call.

Parameters
methodHTTP method
urlURL of the HTTP request
databody of the HTTP request (optional)
data_sizelength of the body
proccallback function for the result
proc_clsclosure for proc
Returns
GNUNET_OK if request accepted

Definition at line 1404 of file reclaim_plugin.c.

1408{
1409 struct RequestHandle *handle = GNUNET_new (struct RequestHandle);
1411 static const struct GNUNET_REST_RequestHandler handlers[] =
1412 { { MHD_HTTP_METHOD_GET,
1414 { MHD_HTTP_METHOD_POST,
1416 { MHD_HTTP_METHOD_DELETE,
1418 { MHD_HTTP_METHOD_GET,
1420 { MHD_HTTP_METHOD_POST,
1422 { MHD_HTTP_METHOD_DELETE,
1424 { MHD_HTTP_METHOD_GET,
1426 { MHD_HTTP_METHOD_POST,
1428 { MHD_HTTP_METHOD_POST,
1430 { MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_RECLAIM, &options_cont },
1432
1433 handle->response_code = 0;
1435 handle->proc_cls = proc_cls;
1436 handle->proc = proc;
1437 handle->rest_handle = rest_handle;
1438
1439 handle->url = GNUNET_strdup (rest_handle->url);
1440 if (handle->url[strlen (handle->url) - 1] == '/')
1441 handle->url[strlen (handle->url) - 1] = '\0';
1442 handle->timeout_task =
1446 handle);
1447 if (GNUNET_NO ==
1448 GNUNET_REST_handle_request (handle->rest_handle, handlers, &err, handle))
1449 {
1451 return GNUNET_NO;
1452 }
1453
1454 return GNUNET_YES;
1455}
struct GNUNET_MQ_MessageHandlers handlers[]
Definition: 003.c:1
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
@ GNUNET_NO
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
#define GNUNET_REST_HANDLER_END
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
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
#define GNUNET_REST_API_NS_IDENTITY_REVOKE
Revoke namespace.
static void do_timeout(void *cls)
Task run on timeout, sends error message.
#define GNUNET_REST_API_NS_IDENTITY_CONSUME
Revoke 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)
#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.
static void list_tickets_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
List tickets for identity request.
static void options_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
Respond to OPTIONS request.
static void list_credential_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
Lists credential for identity request.
static void add_credential_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
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 char * url
The url as string.
void(* proc)(struct GNUNET_REST_RequestHandle *handle, const char *url, void *cls)
Namespace to handle.

References add_attribute_cont(), add_credential_cont(), cleanup_handle(), consume_ticket_cont(), delete_attribute_cont(), delete_credential_cont(), do_timeout(), GNUNET_CONTAINER_DLL_insert, GNUNET_new, GNUNET_NO, GNUNET_REST_API_NS_IDENTITY_CONSUME, GNUNET_REST_API_NS_IDENTITY_REVOKE, GNUNET_REST_API_NS_IDENTITY_TICKETS, GNUNET_REST_API_NS_RECLAIM, GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, GNUNET_REST_API_NS_RECLAIM_CREDENTIAL, GNUNET_REST_handle_request(), GNUNET_REST_HANDLER_END, GNUNET_SCHEDULER_add_delayed(), GNUNET_strdup, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, handle, handlers, list_attribute_cont(), list_credential_cont(), list_tickets_cont(), options_cont(), GNUNET_REST_RequestHandler::proc, requests_head, requests_tail, revoke_ticket_cont(), and GNUNET_REST_RequestHandle::url.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ REST_reclaim_init()

void * REST_reclaim_init ( struct GNUNET_CONFIGURATION_Handle c)

Entry point for the plugin.

Parameters
clsConfig info
Returns
NULL on error, otherwise the plugin context

Definition at line 1465 of file reclaim_plugin.c.

1466{
1467 static struct Plugin plugin;
1468 struct GNUNET_REST_Plugin *api;
1469
1470 rcfg = c;
1471 if (NULL != plugin.cfg)
1472 return NULL; /* can only initialize once! */
1473 memset (&plugin, 0, sizeof(struct Plugin));
1474 plugin.cfg = rcfg;
1475 api = GNUNET_new (struct GNUNET_REST_Plugin);
1476 api->cls = &plugin;
1479 "%s, %s, %s, %s, %s",
1480 MHD_HTTP_METHOD_GET,
1481 MHD_HTTP_METHOD_POST,
1482 MHD_HTTP_METHOD_PUT,
1483 MHD_HTTP_METHOD_DELETE,
1484 MHD_HTTP_METHOD_OPTIONS);
1489 _ ("Identity Provider REST API initialized\n"));
1490 return api;
1491}
struct TestcasePlugin * plugin
The process handle to the testbed service.
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
struct GNUNET_RECLAIM_Handle * GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the re:claimID service.
Definition: reclaim_api.c:1118
#define _(String)
GNU gettext support macro.
Definition: platform.h:178
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 struct GNUNET_IDENTITY_Handle * identity_handle
Handle to Identity service.
const struct GNUNET_CONFIGURATION_Handle * rcfg
The configuration handle.
struct returned by the initialization function of the plugin
char * name
Plugin name.
void * cls
The closure of the plugin.
Handle for a plugin.
Definition: block.c:38

References _, allow_methods, GNUNET_REST_Plugin::cls, GNUNET_asprintf(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_IDENTITY_connect(), GNUNET_log, GNUNET_new, GNUNET_RECLAIM_connect(), GNUNET_REST_API_NS_RECLAIM, ID_REST_STATE_INIT, identity_handle, idp, list_ego(), GNUNET_REST_Plugin::name, plugin, rcfg, and state.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ REST_reclaim_done()

void * REST_reclaim_done ( struct GNUNET_REST_Plugin api)

Exit point from the plugin.

Parameters
clsthe plugin context (as returned by "init")
Returns
always NULL

Definition at line 1501 of file reclaim_plugin.c.

1502{
1503 struct Plugin *plugin = api->cls;
1504 struct RequestHandle *request;
1505 struct EgoEntry *ego_entry;
1506 struct EgoEntry *ego_tmp;
1507
1508 plugin->cfg = NULL;
1509 while (NULL != (request = requests_head))
1510 do_error (request);
1511 if (NULL != idp)
1513 if (NULL != identity_handle)
1515 for (ego_entry = ego_head; NULL != ego_entry;)
1516 {
1517 ego_tmp = ego_entry;
1518 ego_entry = ego_entry->next;
1519 GNUNET_free (ego_tmp->identifier);
1520 GNUNET_free (ego_tmp->keystring);
1521 GNUNET_free (ego_tmp);
1522 }
1523
1525 GNUNET_free (api);
1527 "Identity Provider REST plugin is finished\n");
1528 return NULL;
1529}
static struct GNUNET_VPN_RedirectionRequest * request
Opaque redirection request handle.
Definition: gnunet-vpn.c:40
void GNUNET_IDENTITY_disconnect(struct GNUNET_IDENTITY_Handle *h)
Disconnect from identity service.
Definition: identity_api.c:732
void GNUNET_RECLAIM_disconnect(struct GNUNET_RECLAIM_Handle *h)
Disconnect from identity provider service.
Definition: reclaim_api.c:1150
void * cls
Closure for all of the callbacks.
struct GNUNET_BLOCK_PluginFunctions * api
Plugin API.
Definition: block.c:47

References allow_methods, Plugin::api, GNUNET_BLOCK_PluginFunctions::cls, do_error(), ego_head, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_IDENTITY_disconnect(), GNUNET_log, GNUNET_RECLAIM_disconnect(), EgoEntry::identifier, identity_handle, idp, EgoEntry::keystring, EgoEntry::next, plugin, request, and requests_head.

Referenced by do_shutdown().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ rcfg

const struct GNUNET_CONFIGURATION_Handle* rcfg

The configuration handle.

Definition at line 83 of file reclaim_plugin.c.

Referenced by REST_reclaim_init().

◆ allow_methods

char* allow_methods
static

HTTP methods allows for this plugin.

Definition at line 88 of file reclaim_plugin.c.

Referenced by delete_finished_cb(), finished_cont(), options_cont(), REST_reclaim_done(), REST_reclaim_init(), and return_response().

◆ ego_head

◆ ego_tail

struct EgoEntry* ego_tail
static

Ego list.

Definition at line 98 of file reclaim_plugin.c.

Referenced by list_ego().

◆ state

int state
static

The processing state.

Definition at line 103 of file reclaim_plugin.c.

Referenced by list_ego(), and REST_reclaim_init().

◆ identity_handle

struct GNUNET_IDENTITY_Handle* identity_handle
static

Handle to Identity service.

Definition at line 108 of file reclaim_plugin.c.

Referenced by REST_reclaim_done(), and REST_reclaim_init().

◆ idp

◆ requests_head

struct RequestHandle* requests_head
static

DLL.

Definition at line 261 of file reclaim_plugin.c.

Referenced by cleanup_handle(), REST_reclaim_done(), and REST_reclaim_process_request().

◆ requests_tail

struct RequestHandle* requests_tail
static

DLL.

Definition at line 266 of file reclaim_plugin.c.

Referenced by cleanup_handle(), and REST_reclaim_process_request().