GNUnet  0.11.x
Data Structures | Macros | Functions | Variables
plugin_rest_reclaim.c File Reference

GNUnet reclaim REST plugin. More...

#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 plugin_rest_reclaim.c:

Go to the source code of this file.

Data Structures

struct  Plugin
 Handle for a plugin. More...
 
struct  EgoEntry
 The ego list. 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_ATTESTATION   "/reclaim/attestation"
 Attestation 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 (struct RequestHandle *handle)
 Cleanup lookup handle. More...
 
static void cleanup_handle_delayed (void *cls)
 
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)
 Collect all attributes for an ego. More...
 
static void add_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
 
static void attest_collect (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_Attestation *attest)
 Collect all attestations for an ego. More...
 
static void list_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
 Lists attestation for identity request. More...
 
static void delete_attestation_cont (struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
 Deletes attestation 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_Attestation *attest, 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_EcdsaPublicKey *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_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_Attribute *attr, const struct GNUNET_RECLAIM_Attestation *attest)
 
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 init_cont (struct RequestHandle *handle)
 Handle rest 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...
 
static void rest_identity_process_request (struct GNUNET_REST_RequestHandle *rest_handle, GNUNET_REST_ResultProcessor proc, void *proc_cls)
 
void * libgnunet_plugin_rest_reclaim_init (void *cls)
 Entry point for the plugin. More...
 
void * libgnunet_plugin_rest_reclaim_done (void *cls)
 Exit point from the plugin. More...
 

Variables

const struct GNUNET_CONFIGURATION_Handlecfg
 The configuration handle. More...
 
static char * allow_methods
 HTTP methods allows for this plugin. More...
 

Detailed Description

GNUnet reclaim REST plugin.

Author
Martin Schanzenbach
Philippe Buschmann

Definition in file plugin_rest_reclaim.c.

Macro Definition Documentation

◆ GNUNET_REST_API_NS_RECLAIM

#define GNUNET_REST_API_NS_RECLAIM   "/reclaim"

REST root namespace.

Definition at line 43 of file plugin_rest_reclaim.c.

Referenced by init_cont(), and libgnunet_plugin_rest_reclaim_init().

◆ GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES

#define GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES   "/reclaim/attributes"

◆ GNUNET_REST_API_NS_RECLAIM_ATTESTATION

#define GNUNET_REST_API_NS_RECLAIM_ATTESTATION   "/reclaim/attestation"

◆ GNUNET_REST_API_NS_IDENTITY_TICKETS

#define GNUNET_REST_API_NS_IDENTITY_TICKETS   "/reclaim/tickets"

Ticket namespace.

Definition at line 58 of file plugin_rest_reclaim.c.

Referenced by init_cont(), and list_tickets_cont().

◆ GNUNET_REST_API_NS_IDENTITY_REVOKE

#define GNUNET_REST_API_NS_IDENTITY_REVOKE   "/reclaim/revoke"

Revoke namespace.

Definition at line 63 of file plugin_rest_reclaim.c.

Referenced by init_cont().

◆ GNUNET_REST_API_NS_IDENTITY_CONSUME

#define GNUNET_REST_API_NS_IDENTITY_CONSUME   "/reclaim/consume"

Revoke namespace.

Definition at line 68 of file plugin_rest_reclaim.c.

Referenced by init_cont().

◆ ID_REST_STATE_INIT

#define ID_REST_STATE_INIT   0

State while collecting all egos.

Definition at line 73 of file plugin_rest_reclaim.c.

Referenced by list_ego(), and rest_identity_process_request().

◆ ID_REST_STATE_POST_INIT

#define ID_REST_STATE_POST_INIT   1

Done collecting egos.

Definition at line 78 of file plugin_rest_reclaim.c.

Referenced by list_ego().

Function Documentation

◆ cleanup_handle()

static void cleanup_handle ( struct RequestHandle handle)
static

Cleanup lookup handle.

Parameters
handleHandle to clean up

Definition at line 254 of file plugin_rest_reclaim.c.

References RequestHandle::attest_it, RequestHandle::attr_it, RequestHandle::attr_list, RequestHandle::ego_head, RequestHandle::emsg, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_IDENTITY_disconnect(), GNUNET_log, GNUNET_RECLAIM_attribute_list_destroy(), GNUNET_RECLAIM_disconnect(), GNUNET_RECLAIM_get_attestations_stop(), GNUNET_RECLAIM_get_attributes_stop(), GNUNET_RECLAIM_ticket_iteration_stop(), GNUNET_SCHEDULER_cancel(), EgoEntry::identifier, RequestHandle::identity_handle, RequestHandle::idp, EgoEntry::keystring, EgoEntry::next, RequestHandle::resp_object, RequestHandle::ticket_it, RequestHandle::timeout_task, and RequestHandle::url.

Referenced by cleanup_handle_delayed(), options_cont(), and return_response().

255 {
256  struct EgoEntry *ego_entry;
257  struct EgoEntry *ego_tmp;
258 
259  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n");
260  if (NULL != handle->resp_object)
261  json_decref (handle->resp_object);
262  if (NULL != handle->timeout_task)
264  if (NULL != handle->identity_handle)
266  if (NULL != handle->attr_it)
268  if (NULL != handle->attest_it)
270  if (NULL != handle->ticket_it)
272  if (NULL != handle->idp)
273  GNUNET_RECLAIM_disconnect (handle->idp);
274  if (NULL != handle->url)
275  GNUNET_free (handle->url);
276  if (NULL != handle->emsg)
277  GNUNET_free (handle->emsg);
278  if (NULL != handle->attr_list)
280  for (ego_entry = handle->ego_head; NULL != ego_entry;)
281  {
282  ego_tmp = ego_entry;
283  ego_entry = ego_entry->next;
284  GNUNET_free (ego_tmp->identifier);
285  GNUNET_free (ego_tmp->keystring);
286  GNUNET_free (ego_tmp);
287  }
288  GNUNET_free (handle);
289 }
void GNUNET_RECLAIM_attribute_list_destroy(struct GNUNET_RECLAIM_AttributeList *attrs)
Destroy claim list.
struct GNUNET_RECLAIM_AttributeIterator * attr_it
Attribute iterator.
struct GNUNET_RECLAIM_AttestationIterator * attest_it
Attestation iterator.
void GNUNET_RECLAIM_disconnect(struct GNUNET_RECLAIM_Handle *h)
Disconnect from identity provider service.
Definition: reclaim_api.c:1066
void GNUNET_RECLAIM_ticket_iteration_stop(struct GNUNET_RECLAIM_TicketIterator *it)
Stops iteration and releases the handle for further calls.
Definition: reclaim_api.c:1661
The ego list.
json_t * resp_object
Response object.
char * emsg
Error response message.
struct GNUNET_RECLAIM_TicketIterator * ticket_it
Ticket iterator.
void GNUNET_IDENTITY_disconnect(struct GNUNET_IDENTITY_Handle *h)
Disconnect from identity service.
Definition: identity_api.c:837
char * keystring
Public key string.
struct GNUNET_RECLAIM_Handle * idp
Identity Provider.
char * identifier
Ego Identifier.
struct GNUNET_RECLAIM_AttributeList * attr_list
Attribute claim list.
struct EgoEntry * ego_head
Ego 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:1360
struct GNUNET_SCHEDULER_Task * timeout_task
ID of a task associated with the resolution process.
#define GNUNET_log(kind,...)
struct EgoEntry * next
DLL.
void GNUNET_RECLAIM_get_attestations_stop(struct GNUNET_RECLAIM_AttestationIterator *ait)
Stops iteration and releases the handle for further calls.
Definition: reclaim_api.c:1471
struct GNUNET_IDENTITY_Handle * identity_handle
Handle to Identity service.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:974
char * url
The url.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cleanup_handle_delayed()

static void cleanup_handle_delayed ( void *  cls)
static

Definition at line 293 of file plugin_rest_reclaim.c.

References cleanup_handle().

Referenced by delete_finished_cb(), do_error(), and finished_cont().

294 {
295  cleanup_handle (cls);
296 }
static void cleanup_handle(struct RequestHandle *handle)
Cleanup lookup handle.
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 305 of file plugin_rest_reclaim.c.

References cleanup_handle_delayed(), RequestHandle::emsg, GNUNET_asprintf(), GNUNET_free, GNUNET_REST_create_response(), GNUNET_SCHEDULER_add_now(), handle, RequestHandle::proc, RequestHandle::proc_cls, and RequestHandle::response_code.

Referenced by add_attestation_cont(), add_attribute_cont(), collect_error_cb(), consume_ticket_cont(), delete_attestation_cont(), delete_attribute_cont(), delete_finished_cb(), do_timeout(), finished_cont(), init_cont(), list_attestation_cont(), list_attribute_cont(), list_tickets_cont(), and revoke_ticket_cont().

306 {
307  struct RequestHandle *handle = cls;
308  struct MHD_Response *resp;
309  char *json_error;
310 
311  GNUNET_asprintf (&json_error, "{ \"error\" : \"%s\" }", handle->emsg);
312  if (0 == handle->response_code)
313  {
314  handle->response_code = MHD_HTTP_BAD_REQUEST;
315  }
316  resp = GNUNET_REST_create_response (json_error);
317  MHD_add_response_header (resp, "Content-Type", "application/json");
318  handle->proc (handle->proc_cls, resp, handle->response_code);
320  GNUNET_free (json_error);
321 }
static void cleanup_handle_delayed(void *cls)
GNUNET_REST_ResultProcessor proc
The plugin result processor.
void * proc_cls
The closure of the result processor.
The request handle.
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
char * emsg
Error response message.
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:1298
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
int response_code
Response code.
struct MHD_Response * GNUNET_REST_create_response(const char *data)
Create REST MHD response.
Definition: rest.c:57
#define GNUNET_free(ptr)
Wrapper around free.
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 330 of file plugin_rest_reclaim.c.

References do_error(), handle, and RequestHandle::timeout_task.

Referenced by rest_identity_process_request().

331 {
332  struct RequestHandle *handle = cls;
333 
334  handle->timeout_task = NULL;
335  do_error (handle);
336 }
The request handle.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
static void do_error(void *cls)
Task run on error, sends error message.
struct GNUNET_SCHEDULER_Task * timeout_task
ID of a task associated with the resolution process.
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 340 of file plugin_rest_reclaim.c.

References do_error(), and handle.

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

341 {
342  struct RequestHandle *handle = cls;
343 
344  do_error (handle);
345 }
The request handle.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
static void do_error(void *cls)
Task run on error, sends error message.
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 349 of file plugin_rest_reclaim.c.

References cleanup_handle_delayed(), do_error(), GNUNET_OK, GNUNET_REST_create_response(), GNUNET_SCHEDULER_add_now(), handle, RequestHandle::proc, and RequestHandle::proc_cls.

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

350 {
351  struct RequestHandle *handle = cls;
352  struct MHD_Response *resp;
353 
354  resp = GNUNET_REST_create_response (emsg);
355  if (GNUNET_OK != success)
356  {
358  return;
359  }
360  handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
362 }
static void cleanup_handle_delayed(void *cls)
GNUNET_REST_ResultProcessor proc
The plugin result processor.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
void * proc_cls
The closure of the result processor.
The request handle.
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:1298
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
static void do_error(void *cls)
Task run on error, sends error message.
struct MHD_Response * GNUNET_REST_create_response(const char *data)
Create REST MHD response.
Definition: rest.c:57
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 366 of file plugin_rest_reclaim.c.

References cleanup_handle_delayed(), do_error(), GNUNET_OK, GNUNET_REST_create_response(), GNUNET_SCHEDULER_add_now(), handle, RequestHandle::proc, and RequestHandle::proc_cls.

Referenced by delete_attestation_cont(), and delete_attribute_cont().

367 {
368  struct RequestHandle *handle = cls;
369  struct MHD_Response *resp;
370 
371  resp = GNUNET_REST_create_response (emsg);
372  if (GNUNET_OK != success)
373  {
375  return;
376  }
377  handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
379 }
static void cleanup_handle_delayed(void *cls)
GNUNET_REST_ResultProcessor proc
The plugin result processor.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
void * proc_cls
The closure of the result processor.
The request handle.
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:1298
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
static void do_error(void *cls)
Task run on error, sends error message.
struct MHD_Response * GNUNET_REST_create_response(const char *data)
Create REST MHD response.
Definition: rest.c:57
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 388 of file plugin_rest_reclaim.c.

References cleanup_handle(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_REST_create_response(), handle, RequestHandle::proc, RequestHandle::proc_cls, and RequestHandle::resp_object.

Referenced by collect_finished_cb(), consume_cont(), delete_attestation_cont(), delete_attribute_cont(), list_attestation_cont(), list_attribute_cont(), and list_tickets_cont().

389 {
390  char *result_str;
391  struct RequestHandle *handle = cls;
392  struct MHD_Response *resp;
393 
394  result_str = json_dumps (handle->resp_object, 0);
395  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str);
396  resp = GNUNET_REST_create_response (result_str);
397  handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
398  GNUNET_free (result_str);
399  cleanup_handle (handle);
400 }
GNUNET_REST_ResultProcessor proc
The plugin result processor.
void * proc_cls
The closure of the result processor.
The request handle.
json_t * resp_object
Response object.
static void cleanup_handle(struct RequestHandle *handle)
Cleanup lookup handle.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
struct MHD_Response * GNUNET_REST_create_response(const char *data)
Create REST MHD response.
Definition: rest.c:57
#define GNUNET_log(kind,...)
#define GNUNET_free(ptr)
Wrapper around free.
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 404 of file plugin_rest_reclaim.c.

References RequestHandle::attest_it, RequestHandle::attr_it, GNUNET_SCHEDULER_add_now(), handle, return_response(), and RequestHandle::ticket_it.

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

405 {
406  struct RequestHandle *handle = cls;
407 
408  // Done
409  handle->attr_it = NULL;
410  handle->attest_it = NULL;
411  handle->ticket_it = NULL;
413 }
struct GNUNET_RECLAIM_AttributeIterator * attr_it
Attribute iterator.
struct GNUNET_RECLAIM_AttestationIterator * attest_it
Attestation iterator.
The request handle.
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:1298
struct GNUNET_RECLAIM_TicketIterator * ticket_it
Ticket iterator.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
static void return_response(void *cls)
Return attributes for identity.
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 
)
static

Collect all attributes for an ego.

Definition at line 421 of file plugin_rest_reclaim.c.

References GNUNET_RECLAIM_Ticket::audience, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_RECLAIM_ticket_iteration_next(), GNUNET_STRINGS_data_to_string_alloc(), handle, GNUNET_RECLAIM_Ticket::identity, RequestHandle::resp_object, GNUNET_RECLAIM_Ticket::rnd, RequestHandle::ticket_it, and value.

Referenced by list_tickets_cont().

422 {
423  json_t *json_resource;
424  struct RequestHandle *handle = cls;
425  json_t *value;
426  char *tmp;
427 
428  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding ticket\n");
429  tmp = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof(ticket->rnd));
430  json_resource = json_object ();
431  GNUNET_free (tmp);
432  json_array_append (handle->resp_object, json_resource);
433 
434  tmp =
436  sizeof(struct
438  value = json_string (tmp);
439  json_object_set_new (json_resource, "issuer", value);
440  GNUNET_free (tmp);
441  tmp =
443  sizeof(struct
445  value = json_string (tmp);
446  json_object_set_new (json_resource, "audience", value);
447  GNUNET_free (tmp);
448  tmp = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof(ticket->rnd));
449  value = json_string (tmp);
450  json_object_set_new (json_resource, "rnd", value);
451  GNUNET_free (tmp);
453 }
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:1641
The request handle.
json_t * resp_object
Response object.
static char * value
Value of the record to add/remove.
struct GNUNET_RECLAIM_TicketIterator * ticket_it
Ticket iterator.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
struct GNUNET_CRYPTO_EcdsaPublicKey identity
The ticket issuer (= the user)
struct GNUNET_RECLAIM_Identifier rnd
The ticket random identifier.
struct GNUNET_CRYPTO_EcdsaPublicKey audience
The ticket audience (= relying party)
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
#define GNUNET_log(kind,...)
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:935
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_attestation_cont()

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

New ID for attribute

Definition at line 457 of file plugin_rest_reclaim.c.

References GNUNET_REST_RequestHandle::data, GNUNET_REST_RequestHandle::data_size, do_error(), EgoEntry::ego, RequestHandle::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_attestation_store(), GNUNET_RECLAIM_connect(), GNUNET_RECLAIM_id_generate, GNUNET_RECLAIM_id_is_zero, GNUNET_RECLAIM_JSON_spec_claim_attest(), GNUNET_REST_API_NS_RECLAIM_ATTESTATION, GNUNET_SCHEDULER_add_now(), GNUNET_TIME_UNIT_HOURS, GNUNET_YES, handle, GNUNET_RECLAIM_Attestation::id, EgoEntry::identifier, identity, RequestHandle::idp, RequestHandle::idp_op, EgoEntry::next, RequestHandle::rest_handle, and RequestHandle::url.

Referenced by init_cont().

460 {
461  struct RequestHandle *handle = cls;
462  const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv;
463  const char *identity;
464  struct EgoEntry *ego_entry;
465  struct GNUNET_RECLAIM_Attestation *attribute;
466  struct GNUNET_TIME_Relative exp;
467  char term_data[handle->rest_handle->data_size + 1];
468  json_t *data_json;
469  json_error_t err;
470  struct GNUNET_JSON_Specification attrspec[] =
473 
475  "Adding an attestation for %s.\n",
476  handle->url);
477  if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION) >= strlen (
478  handle->url))
479  {
480  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
482  return;
483  }
484  identity = handle->url + strlen (
486 
487  for (ego_entry = handle->ego_head; NULL != ego_entry;
488  ego_entry = ego_entry->next)
489  if (0 == strcmp (identity, ego_entry->identifier))
490  break;
491 
492  if (NULL == ego_entry)
493  {
494  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Identity unknown (%s)\n", identity);
495  return;
496  }
497  identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
498 
499  if (0 >= handle->rest_handle->data_size)
500  {
502  return;
503  }
504 
505  term_data[handle->rest_handle->data_size] = '\0';
506  GNUNET_memcpy (term_data,
507  handle->rest_handle->data,
508  handle->rest_handle->data_size);
509  data_json = json_loads (term_data, JSON_DECODE_ANY, &err);
511  GNUNET_JSON_parse (data_json, attrspec, NULL, NULL));
512  json_decref (data_json);
513  if (NULL == attribute)
514  {
516  "Unable to parse attestation from %s\n",
517  term_data);
519  return;
520  }
524  if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&attribute->id))
525  GNUNET_RECLAIM_id_generate (&attribute->id);
526  handle->idp = GNUNET_RECLAIM_connect (cfg);
528  handle->idp_op = GNUNET_RECLAIM_attestation_store (handle->idp,
529  identity_priv,
530  attribute,
531  &exp,
532  &finished_cont,
533  handle);
534  GNUNET_JSON_parse_free (attrspec);
535 }
#define GNUNET_TIME_UNIT_HOURS
One hour.
size_t data_size
The POST data size.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GNUNET_JSON_parse_free(struct GNUNET_JSON_Specification *spec)
Frees all elements allocated during a GNUNET_JSON_parse() operation.
Definition: json.c:100
static void finished_cont(void *cls, int32_t success, const char *emsg)
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:555
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
Entry in parser specification for GNUNET_JSON_parse().
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
Private ECC key encoded for transmission.
The request handle.
The ego list.
struct GNUNET_IDENTITY_Ego * ego
The Ego.
int 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:45
#define GNUNET_REST_API_NS_RECLAIM_ATTESTATION
Attestation namespace.
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:1298
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration handle.
struct GNUNET_REST_RequestHandle * rest_handle
Rest connection.
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_attestation_store(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const struct GNUNET_RECLAIM_Attestation *attestation, const struct GNUNET_TIME_Relative *exp_interval, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
Store an attestation.
Definition: reclaim_api.c:1189
struct GNUNET_RECLAIM_Identifier id
ID.
const char * data
The POST data.
struct GNUNET_RECLAIM_Handle * idp
Identity Provider.
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
static void do_error(void *cls)
Task run on error, sends error message.
char * identifier
Ego Identifier.
struct EgoEntry * ego_head
Ego list.
#define GNUNET_log(kind,...)
struct GNUNET_RECLAIM_Operation * idp_op
Idp Operation.
#define GNUNET_YES
Definition: gnunet_common.h:85
struct GNUNET_JSON_Specification GNUNET_JSON_spec_end(void)
End of a parser specification.
Definition: json_helper.c:35
#define GNUNET_RECLAIM_id_generate(id)
struct GNUNET_RECLAIM_Handle * GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the re:claimID service.
Definition: reclaim_api.c:1026
struct EgoEntry * next
DLL.
struct GNUNET_JSON_Specification GNUNET_RECLAIM_JSON_spec_claim_attest(struct GNUNET_RECLAIM_Attestation **attr)
JSON Specification for Reclaim attestation claims.
Definition: json_reclaim.c:377
Time for relative time used by GNUnet, in microseconds.
#define GNUNET_RECLAIM_id_is_zero(a)
char * url
The url.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ attest_collect()

static void attest_collect ( void *  cls,
const struct GNUNET_CRYPTO_EcdsaPublicKey identity,
const struct GNUNET_RECLAIM_Attestation attest 
)
static

Collect all attestations for an ego.

Definition at line 543 of file plugin_rest_reclaim.c.

References GNUNET_TIME_Absolute::abs_value_us, RequestHandle::attest_it, GNUNET_RECLAIM_AttributeListEntry::attribute, GNUNET_RECLAIM_Attribute::data, GNUNET_RECLAIM_Attestation::data, GNUNET_RECLAIM_Attribute::data_size, GNUNET_RECLAIM_Attestation::data_size, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_OK, GNUNET_RECLAIM_attestation_get_attributes(), GNUNET_RECLAIM_attestation_get_expiration(), GNUNET_RECLAIM_attestation_get_issuer(), GNUNET_RECLAIM_attestation_number_to_typename(), GNUNET_RECLAIM_attestation_value_to_string(), GNUNET_RECLAIM_attribute_list_destroy(), GNUNET_RECLAIM_attribute_number_to_typename(), GNUNET_RECLAIM_attribute_value_to_string(), GNUNET_RECLAIM_get_attestations_next(), GNUNET_STRINGS_data_to_string_alloc(), handle, GNUNET_RECLAIM_Attestation::id, GNUNET_RECLAIM_AttributeList::list_head, GNUNET_RECLAIM_Attribute::name, GNUNET_RECLAIM_Attestation::name, GNUNET_RECLAIM_AttributeListEntry::next, RequestHandle::resp_object, GNUNET_RECLAIM_Attribute::type, type, and GNUNET_RECLAIM_Attestation::type.

Referenced by list_attestation_cont().

546 {
547  struct RequestHandle *handle = cls;
548  struct GNUNET_RECLAIM_AttributeList *attrs;
550  struct GNUNET_TIME_Absolute exp;
551  json_t *attr_obj;
552  json_t *attest_obj;
553  const char *type;
554  char *tmp_value;
555  char *id_str;
556  char *issuer;
557 
558 
559  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attestation: %s\n",
560  attest->name);
562  issuer = GNUNET_RECLAIM_attestation_get_issuer (attest);
564  attest->data,
565  attest->data_size);
566  attest_obj = json_object ();
567  json_object_set_new (attest_obj, "value", json_string (tmp_value));
568  json_object_set_new (attest_obj, "name", json_string (attest->name));
570  json_object_set_new (attest_obj, "type", json_string (type));
571  if (NULL != issuer)
572  {
573  json_object_set_new (attest_obj, "issuer", json_string (issuer));
574  GNUNET_free (issuer);
575  }
577  &exp))
578  {
579  json_object_set_new (attest_obj, "expiration", json_integer (exp.abs_value_us));
580  }
581  id_str = GNUNET_STRINGS_data_to_string_alloc (&attest->id,
582  sizeof(attest->id));
583  json_object_set_new (attest_obj, "id", json_string (id_str));
584  GNUNET_free (tmp_value);
585  GNUNET_free (id_str);
586  if (NULL != attrs)
587  {
588  json_t *attr_arr = json_array ();
589  for (ale = attrs->list_head; NULL != ale; ale = ale->next)
590  {
591  tmp_value =
593  ale->attribute->data,
594  ale->attribute->data_size);
595  attr_obj = json_object ();
596  json_object_set_new (attr_obj, "value", json_string (tmp_value));
597  json_object_set_new (attr_obj, "name", json_string (
598  ale->attribute->name));
599 
600  json_object_set_new (attr_obj, "flag", json_string ("1")); //FIXME
602  json_object_set_new (attr_obj, "type", json_string (type));
603  json_object_set_new (attr_obj, "id", json_string (""));
604  json_object_set_new (attr_obj, "attestation", json_string (""));
605  json_array_append_new (attr_arr, attr_obj);
606  GNUNET_free (tmp_value);
607  }
608  json_object_set_new (attest_obj, "attributes", attr_arr);
609  }
610  json_array_append_new (handle->resp_object, attest_obj);
613 }
struct GNUNET_RECLAIM_AttributeList * GNUNET_RECLAIM_attestation_get_attributes(const struct GNUNET_RECLAIM_Attestation *attest)
Convert an attestation type name to the corresponding number.
void GNUNET_RECLAIM_attribute_list_destroy(struct GNUNET_RECLAIM_AttributeList *attrs)
Destroy claim list.
const char * name
The name of the attribute.
struct GNUNET_RECLAIM_AttestationIterator * attest_it
Attestation iterator.
A list of GNUNET_RECLAIM_Attribute structures.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
void GNUNET_RECLAIM_get_attestations_next(struct GNUNET_RECLAIM_AttestationIterator *ait)
Calls the record processor specified in #GNUNET_RECLAIM_get_attestation_start for the next record...
Definition: reclaim_api.c:1449
struct GNUNET_RECLAIM_Attribute * attribute
The attribute claim.
The request handle.
char * GNUNET_RECLAIM_attestation_value_to_string(uint32_t type, const void *data, size_t data_size)
Convert the &#39;claim&#39; of an attestation to a string.
json_t * resp_object
Response object.
const char * GNUNET_RECLAIM_attestation_number_to_typename(uint32_t type)
Convert an attestation type number to the corresponding attestation type string.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
int GNUNET_RECLAIM_attestation_get_expiration(const struct GNUNET_RECLAIM_Attestation *attest, struct GNUNET_TIME_Absolute *exp)
size_t data_size
Number of bytes in data.
size_t data_size
Number of bytes in data.
const char * name
The name of the attribute.
struct GNUNET_RECLAIM_Identifier id
ID.
uint32_t type
Type/Format of Claim.
struct GNUNET_RECLAIM_AttributeListEntry * next
DLL.
const void * data
Binary value stored as attribute value.
const char * GNUNET_RECLAIM_attribute_number_to_typename(uint32_t type)
Convert a type number to the corresponding type string.
#define GNUNET_log(kind,...)
char * GNUNET_RECLAIM_attestation_get_issuer(const struct GNUNET_RECLAIM_Attestation *attest)
const void * data
Binary value stored as attribute value.
char * GNUNET_RECLAIM_attribute_value_to_string(uint32_t type, const void *data, size_t data_size)
Convert the &#39;claim&#39; of an attribute to a string.
uint32_t type
Type of Claim.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
Time for absolute times used by GNUnet, in microseconds.
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:935
struct GNUNET_RECLAIM_AttributeListEntry * list_head
List head.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ list_attestation_cont()

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

Lists attestation for identity request.

Parameters
con_handlethe connection handle
urlthe url
clsthe RequestHandle

Definition at line 624 of file plugin_rest_reclaim.c.

References attest_collect(), RequestHandle::attest_it, collect_error_cb(), collect_finished_cb(), do_error(), EgoEntry::ego, RequestHandle::ego_head, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_IDENTITY_ego_get_private_key(), GNUNET_log, GNUNET_RECLAIM_connect(), GNUNET_RECLAIM_get_attestations_start(), GNUNET_REST_API_NS_RECLAIM_ATTESTATION, GNUNET_SCHEDULER_add_now(), handle, EgoEntry::identifier, identity, RequestHandle::idp, EgoEntry::next, RequestHandle::resp_object, return_response(), and RequestHandle::url.

Referenced by init_cont().

627 {
628  struct RequestHandle *handle = cls;
629  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key;
630  struct EgoEntry *ego_entry;
631  char *identity;
632 
634  "Getting attestations for %s.\n",
635  handle->url);
636  if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION) >= strlen (
637  handle->url))
638  {
639  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
641  return;
642  }
643  identity = handle->url + strlen (
645 
646  for (ego_entry = handle->ego_head; NULL != ego_entry;
647  ego_entry = ego_entry->next)
648  if (0 == strcmp (identity, ego_entry->identifier))
649  break;
650  handle->resp_object = json_array ();
651 
652 
653  if (NULL == ego_entry)
654  {
655  // Done
656  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
658  return;
659  }
660  priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
661  handle->idp = GNUNET_RECLAIM_connect (cfg);
663  priv_key,
665  handle,
667  handle,
668  &
670  handle);
671 }
struct GNUNET_RECLAIM_AttestationIterator * GNUNET_RECLAIM_get_attestations_start(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_RECLAIM_AttestationResult proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
List all attestations for a local identity.
Definition: reclaim_api.c:1402
static void collect_error_cb(void *cls)
struct GNUNET_RECLAIM_AttestationIterator * attest_it
Attestation iterator.
static void attest_collect(void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_Attestation *attest)
Collect all attestations for an ego.
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:555
Private ECC key encoded for transmission.
static void collect_finished_cb(void *cls)
The request handle.
The ego list.
struct GNUNET_IDENTITY_Ego * ego
The Ego.
json_t * resp_object
Response object.
#define GNUNET_REST_API_NS_RECLAIM_ATTESTATION
Attestation namespace.
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:1298
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration handle.
static void return_response(void *cls)
Return attributes for identity.
struct GNUNET_RECLAIM_Handle * idp
Identity Provider.
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
static void do_error(void *cls)
Task run on error, sends error message.
char * identifier
Ego Identifier.
struct EgoEntry * ego_head
Ego list.
#define GNUNET_log(kind,...)
struct GNUNET_RECLAIM_Handle * GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the re:claimID service.
Definition: reclaim_api.c:1026
struct EgoEntry * next
DLL.
char * url
The url.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ delete_attestation_cont()

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

Deletes attestation from an identity.

Parameters
con_handlethe connection handle
urlthe url
clsthe RequestHandle

Definition at line 682 of file plugin_rest_reclaim.c.

References delete_finished_cb(), do_error(), EgoEntry::ego, RequestHandle::ego_head, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_IDENTITY_ego_get_private_key(), GNUNET_log, GNUNET_RECLAIM_attestation_delete(), GNUNET_RECLAIM_connect(), GNUNET_REST_API_NS_RECLAIM_ATTESTATION, GNUNET_SCHEDULER_add_now(), GNUNET_STRINGS_string_to_data(), handle, GNUNET_RECLAIM_Attestation::id, id, EgoEntry::identifier, identity, RequestHandle::idp, RequestHandle::idp_op, GNUNET_RECLAIM_Attestation::name, EgoEntry::next, RequestHandle::resp_object, return_response(), and RequestHandle::url.

Referenced by init_cont().

685 {
686  struct RequestHandle *handle = cls;
687  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key;
688  struct GNUNET_RECLAIM_Attestation attr;
689  struct EgoEntry *ego_entry;
690  char *identity_id_str;
691  char *identity;
692  char *id;
693 
694  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting attestation.\n");
695  if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTESTATION) >= strlen (
696  handle->url))
697  {
698  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
700  return;
701  }
702  identity_id_str =
703  strdup (handle->url + strlen (
705  identity = strtok (identity_id_str, "/");
706  id = strtok (NULL, "/");
707  if ((NULL == identity) || (NULL == id))
708  {
709  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Malformed request.\n");
710  GNUNET_free (identity_id_str);
712  return;
713  }
714 
715  for (ego_entry = handle->ego_head; NULL != ego_entry;
716  ego_entry = ego_entry->next)
717  if (0 == strcmp (identity, ego_entry->identifier))
718  break;
719  handle->resp_object = json_array ();
720  if (NULL == ego_entry)
721  {
722  // Done
723  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
724  GNUNET_free (identity_id_str);
726  return;
727  }
728  priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
729  handle->idp = GNUNET_RECLAIM_connect (cfg);
730  memset (&attr, 0, sizeof(struct GNUNET_RECLAIM_Attestation));
731  GNUNET_STRINGS_string_to_data (id, strlen (id), &attr.id, sizeof(attr.id));
732  attr.name = "";
733  handle->idp_op = GNUNET_RECLAIM_attestation_delete (handle->idp,
734  priv_key,
735  &attr,
737  handle);
738  GNUNET_free (identity_id_str);
739 }
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:555
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_attestation_delete(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const struct GNUNET_RECLAIM_Attestation *attr, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
Delete an attestation.
Definition: reclaim_api.c:1236
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
Private ECC key encoded for transmission.
The request handle.
The ego list.
struct GNUNET_IDENTITY_Ego * ego
The Ego.
json_t * resp_object
Response object.
#define GNUNET_REST_API_NS_RECLAIM_ATTESTATION
Attestation namespace.
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:1298
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration handle.
static void return_response(void *cls)
Return attributes for identity.
struct GNUNET_RECLAIM_Handle * idp
Identity Provider.
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
static void delete_finished_cb(void *cls, int32_t success, const char *emsg)
static void do_error(void *cls)
Task run on error, sends error message.
char * identifier
Ego Identifier.
struct EgoEntry * ego_head
Ego list.
#define GNUNET_log(kind,...)
struct GNUNET_RECLAIM_Operation * idp_op
Idp Operation.
struct GNUNET_RECLAIM_Handle * GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the re:claimID service.
Definition: reclaim_api.c:1026
struct EgoEntry * next
DLL.
int 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:970
#define GNUNET_free(ptr)
Wrapper around free.
char * url
The url.
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 750 of file plugin_rest_reclaim.c.

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

Referenced by init_cont().

753 {
754  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key;
755  struct RequestHandle *handle = cls;
756  struct EgoEntry *ego_entry;
757  char *identity;
758 
760  "Getting tickets for %s.\n",
761  handle->url);
762  if (strlen (GNUNET_REST_API_NS_IDENTITY_TICKETS) >= strlen (handle->url))
763  {
764  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
766  return;
767  }
768  identity = handle->url + strlen (GNUNET_REST_API_NS_IDENTITY_TICKETS) + 1;
769 
770  for (ego_entry = handle->ego_head; NULL != ego_entry;
771  ego_entry = ego_entry->next)
772  if (0 == strcmp (identity, ego_entry->identifier))
773  break;
774  handle->resp_object = json_array ();
775 
776  if (NULL == ego_entry)
777  {
778  // Done
779  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
781  return;
782  }
783  priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
784  handle->idp = GNUNET_RECLAIM_connect (cfg);
785  handle->ticket_it =
787  priv_key,
789  handle,
791  handle,
793  handle);
794 }
struct GNUNET_RECLAIM_TicketIterator * GNUNET_RECLAIM_ticket_iteration_start(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *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:1597
static void collect_error_cb(void *cls)
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:555
Private ECC key encoded for transmission.
static void collect_finished_cb(void *cls)
The request handle.
The ego list.
struct GNUNET_IDENTITY_Ego * ego
The Ego.
json_t * resp_object
Response object.
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:1298
struct GNUNET_RECLAIM_TicketIterator * ticket_it
Ticket iterator.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration handle.
static void ticket_collect(void *cls, const struct GNUNET_RECLAIM_Ticket *ticket)
Collect all attributes for an ego.
static void return_response(void *cls)
Return attributes for identity.
struct GNUNET_RECLAIM_Handle * idp
Identity Provider.
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
static void do_error(void *cls)
Task run on error, sends error message.
char * identifier
Ego Identifier.
struct EgoEntry * ego_head
Ego list.
#define GNUNET_log(kind,...)
struct GNUNET_RECLAIM_Handle * GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the re:claimID service.
Definition: reclaim_api.c:1026
struct EgoEntry * next
DLL.
#define GNUNET_REST_API_NS_IDENTITY_TICKETS
Ticket namespace.
char * url
The url.
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 798 of file plugin_rest_reclaim.c.

References GNUNET_REST_RequestHandle::data, GNUNET_REST_RequestHandle::data_size, do_error(), EgoEntry::ego, RequestHandle::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_connect(), GNUNET_RECLAIM_id_generate, GNUNET_RECLAIM_id_is_zero, GNUNET_RECLAIM_JSON_spec_claim(), GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, GNUNET_SCHEDULER_add_now(), GNUNET_TIME_UNIT_HOURS, GNUNET_YES, handle, GNUNET_RECLAIM_Attribute::id, EgoEntry::identifier, identity, RequestHandle::idp, RequestHandle::idp_op, EgoEntry::next, RequestHandle::rest_handle, and RequestHandle::url.

Referenced by init_cont().

801 {
802  const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv;
803  const char *identity;
804  struct RequestHandle *handle = cls;
805  struct EgoEntry *ego_entry;
806  struct GNUNET_RECLAIM_Attribute *attribute;
807  struct GNUNET_TIME_Relative exp;
808  char term_data[handle->rest_handle->data_size + 1];
809  json_t *data_json;
810  json_error_t err;
811  struct GNUNET_JSON_Specification attrspec[] =
813 
815  "Adding an attribute for %s.\n",
816  handle->url);
817  if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) >= strlen (handle->url))
818  {
819  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
821  return;
822  }
823  identity = handle->url + strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) + 1;
824 
825  for (ego_entry = handle->ego_head; NULL != ego_entry;
826  ego_entry = ego_entry->next)
827  if (0 == strcmp (identity, ego_entry->identifier))
828  break;
829 
830  if (NULL == ego_entry)
831  {
832  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Identity unknown (%s)\n", identity);
833  return;
834  }
835  identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
836 
837  if (0 >= handle->rest_handle->data_size)
838  {
840  return;
841  }
842 
843  term_data[handle->rest_handle->data_size] = '\0';
844  GNUNET_memcpy (term_data,
845  handle->rest_handle->data,
846  handle->rest_handle->data_size);
847  data_json = json_loads (term_data, JSON_DECODE_ANY, &err);
849  GNUNET_JSON_parse (data_json, attrspec, NULL, NULL));
850  json_decref (data_json);
851  if (NULL == attribute)
852  {
854  "Unable to parse attribute from %s\n",
855  term_data);
857  return;
858  }
862  if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&attribute->id))
863  GNUNET_RECLAIM_id_generate (&attribute->id);
864  handle->idp = GNUNET_RECLAIM_connect (cfg);
866  handle->idp_op = GNUNET_RECLAIM_attribute_store (handle->idp,
867  identity_priv,
868  attribute,
869  &exp,
870  &finished_cont,
871  handle);
872  GNUNET_JSON_parse_free (attrspec);
873 }
#define GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES
Attribute namespace.
#define GNUNET_TIME_UNIT_HOURS
One hour.
size_t data_size
The POST data size.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GNUNET_JSON_parse_free(struct GNUNET_JSON_Specification *spec)
Frees all elements allocated during a GNUNET_JSON_parse() operation.
Definition: json.c:100
static void finished_cont(void *cls, int32_t success, const char *emsg)
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:555
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
Entry in parser specification for GNUNET_JSON_parse().
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
Private ECC key encoded for transmission.
The request handle.
The ego list.
struct GNUNET_IDENTITY_Ego * ego
The Ego.
int 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:45
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:1298
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
struct GNUNET_RECLAIM_Identifier id
ID.
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration handle.
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_attribute_store(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *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:1097
struct GNUNET_REST_RequestHandle * rest_handle
Rest connection.
struct GNUNET_JSON_Specification GNUNET_RECLAIM_JSON_spec_claim(struct GNUNET_RECLAIM_Attribute **attr)
JSON Specification for Reclaim claims.
Definition: json_reclaim.c:147
const char * data
The POST data.
struct GNUNET_RECLAIM_Handle * idp
Identity Provider.
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
static void do_error(void *cls)
Task run on error, sends error message.
char * identifier
Ego Identifier.
struct EgoEntry * ego_head
Ego list.
#define GNUNET_log(kind,...)
struct GNUNET_RECLAIM_Operation * idp_op
Idp Operation.
#define GNUNET_YES
Definition: gnunet_common.h:85
struct GNUNET_JSON_Specification GNUNET_JSON_spec_end(void)
End of a parser specification.
Definition: json_helper.c:35
#define GNUNET_RECLAIM_id_generate(id)
struct GNUNET_RECLAIM_Handle * GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the re:claimID service.
Definition: reclaim_api.c:1026
struct EgoEntry * next
DLL.
Time for relative time used by GNUnet, in microseconds.
#define GNUNET_RECLAIM_id_is_zero(a)
char * url
The url.
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_Attestation attest,
const char *  claim 
)

Parse a JWT and return the respective claim value as Attribute.

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

Definition at line 885 of file plugin_rest_reclaim.c.

References data, GNUNET_RECLAIM_Attestation::data, GNUNET_RECLAIM_Attestation::data_size, data_size, GNUNET_RECLAIM_Attribute::flag, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_RECLAIM_attestation_value_to_string(), GNUNET_RECLAIM_attribute_new(), GNUNET_RECLAIM_attribute_string_to_value(), GNUNET_RECLAIM_attribute_typename_to_number(), GNUNET_STRINGS_base64_decode(), GNUNET_SYSERR, GNUNET_RECLAIM_Attribute::id, GNUNET_RECLAIM_Attestation::id, Plugin::key, type, GNUNET_RECLAIM_Attestation::type, type_str, and value.

887 {
888  char *jwt_string;
889  struct GNUNET_RECLAIM_Attribute *attr;
890  char delim[] = ".";
891  const char *type_str = NULL;
892  const char *val_str = NULL;
893  char *data;
894  size_t data_size;
895  uint32_t type;
896  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Parsing JWT attributes.\n");
897  char *decoded_jwt;
898  json_t *json_val;
899  json_error_t *json_err = NULL;
900 
901  jwt_string = GNUNET_RECLAIM_attestation_value_to_string (attest->type,
902  attest->data,
903  attest->data_size);
904  char *jwt_body = strtok (jwt_string, delim);
905  jwt_body = strtok (NULL, delim);
906  GNUNET_STRINGS_base64_decode (jwt_body, strlen (jwt_body),
907  (void **) &decoded_jwt);
908  json_val = json_loads (decoded_jwt, JSON_DECODE_ANY, json_err);
909  const char *key;
910  json_t *value;
911  json_object_foreach (json_val, key, value) {
912  if (0 == strcasecmp (key,claim))
913  {
914  val_str = json_dumps (value, JSON_ENCODE_ANY);
915  }
916  }
917  type_str = "String";
920  (void **) &data,
921  &data_size))
922  {
924  "Attribute value from JWT Parser invalid!\n");
926  "Error: Referenced Claim Name not Found",
927  (void **) &data,
928  &data_size);
929  attr = GNUNET_RECLAIM_attribute_new (claim, &attest->id,
930  type, data, data_size);
931  attr->id = attest->id;
932  attr->flag = 1;
933  }
934  else
935  {
936  attr = GNUNET_RECLAIM_attribute_new (claim, &attest->id,
937  type, data, data_size);
938  attr->id = attest->id;
939  attr->flag = 1;
940  }
941  return attr;
942 }
struct GNUNET_RECLAIM_Attribute * claim
Claim to store.
static size_t data_size
Number of bytes in data.
Definition: gnunet-abd.c:187
char * GNUNET_RECLAIM_attestation_value_to_string(uint32_t type, const void *data, size_t data_size)
Convert the &#39;claim&#39; of an attestation to a string.
static char * value
Value of the record to add/remove.
uint32_t GNUNET_RECLAIM_attribute_typename_to_number(const char *typename)
Convert a type name to the corresponding number.
struct GNUNET_RECLAIM_Identifier id
ID.
size_t data_size
Number of bytes in data.
size_t GNUNET_STRINGS_base64_decode(const char *data, size_t len, void **output)
Decode from Base64.
Definition: strings.c:1976
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 &#39;claim&#39; of an attribute to the binary representation.
struct GNUNET_RECLAIM_Identifier id
ID.
uint32_t type
Type/Format of Claim.
struct GNUNET_HashCode key
The key used in the DHT.
#define GNUNET_SYSERR
Definition: gnunet_common.h:84
static char * type_str
Attribute type.
struct GNUNET_RECLAIM_Attribute * GNUNET_RECLAIM_attribute_new(const char *attr_name, const struct GNUNET_RECLAIM_Identifier *attestation, uint32_t type, const void *data, size_t data_size)
Create a new attribute claim.
const void * data
Binary value stored as attribute value.
#define GNUNET_log(kind,...)
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
uint32_t data
The data value.
Here is the call graph for this function:

◆ attr_collect()

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

Collect all attributes for an ego.

Definition at line 950 of file plugin_rest_reclaim.c.

References GNUNET_RECLAIM_Attribute::attestation, RequestHandle::attr_it, 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, RequestHandle::resp_object, GNUNET_RECLAIM_Attribute::type, and type.

Referenced by list_attribute_cont().

953 {
954  struct RequestHandle *handle = cls;
955  json_t *attr_obj;
956  const char *type;
957  char *id_str;
958 
959  char *tmp_value;
961  attr->data,
962  attr->data_size);
963  attr_obj = json_object ();
964  json_object_set_new (attr_obj, "value", json_string (tmp_value));
965  json_object_set_new (attr_obj, "name", json_string (attr->name));
966 
968  json_object_set_new (attr_obj, "flag", json_string ("0"));
969  else
970  json_object_set_new (attr_obj, "flag", json_string ("1"));
972  json_object_set_new (attr_obj, "type", json_string (type));
973  id_str = GNUNET_STRINGS_data_to_string_alloc (&attr->id,
974  sizeof(attr->id));
975  json_object_set_new (attr_obj, "id", json_string (id_str));
977  sizeof(attr->attestation));
978  json_object_set_new (attr_obj, "attestation", json_string (id_str));
979  json_array_append (handle->resp_object, attr_obj);
980  json_decref (attr_obj);
981  GNUNET_free (tmp_value);
983 }
struct GNUNET_RECLAIM_AttributeIterator * attr_it
Attribute iterator.
const char * name
The name of the attribute.
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:1339
The request handle.
struct GNUNET_RECLAIM_Identifier attestation
Referenced ID of Attestation (may be 0 if self-attested)
json_t * resp_object
Response object.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
struct GNUNET_RECLAIM_Identifier id
ID.
size_t data_size
Number of bytes in data.
const char * GNUNET_RECLAIM_attribute_number_to_typename(uint32_t type)
Convert a type number to the corresponding type string.
const void * data
Binary value stored as attribute value.
char * GNUNET_RECLAIM_attribute_value_to_string(uint32_t type, const void *data, size_t data_size)
Convert the &#39;claim&#39; of an attribute to a string.
uint32_t type
Type of Claim.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:935
#define GNUNET_free(ptr)
Wrapper around free.
#define GNUNET_RECLAIM_id_is_zero(a)
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 994 of file plugin_rest_reclaim.c.

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

Referenced by init_cont().

997 {
998  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key;
999  struct RequestHandle *handle = cls;
1000  struct EgoEntry *ego_entry;
1001  char *identity;
1002 
1004  "Getting attributes for %s.\n",
1005  handle->url);
1006  if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) >= strlen (handle->url))
1007  {
1008  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
1010  return;
1011  }
1012  identity = handle->url + strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) + 1;
1013 
1014  for (ego_entry = handle->ego_head; NULL != ego_entry;
1015  ego_entry = ego_entry->next)
1016  if (0 == strcmp (identity, ego_entry->identifier))
1017  break;
1018  handle->resp_object = json_array ();
1019 
1020 
1021  if (NULL == ego_entry)
1022  {
1023  // Done
1024  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
1026  return;
1027  }
1028  priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
1029  handle->idp = GNUNET_RECLAIM_connect (cfg);
1030  handle->attr_it = GNUNET_RECLAIM_get_attributes_start (handle->idp,
1031  priv_key,
1033  handle,
1034  &attr_collect,
1035  handle,
1037  handle);
1038 }
#define GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES
Attribute namespace.
struct GNUNET_RECLAIM_AttributeIterator * GNUNET_RECLAIM_get_attributes_start(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *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:1293
static void collect_error_cb(void *cls)
struct GNUNET_RECLAIM_AttributeIterator * attr_it
Attribute iterator.
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:555
Private ECC key encoded for transmission.
static void collect_finished_cb(void *cls)
The request handle.
The ego list.
struct GNUNET_IDENTITY_Ego * ego
The Ego.
json_t * resp_object
Response object.
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:1298
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration handle.
static void return_response(void *cls)
Return attributes for identity.
struct GNUNET_RECLAIM_Handle * idp
Identity Provider.
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
static void do_error(void *cls)
Task run on error, sends error message.
char * identifier
Ego Identifier.
static void attr_collect(void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_Attribute *attr)
Collect all attributes for an ego.
struct EgoEntry * ego_head
Ego list.
#define GNUNET_log(kind,...)
struct GNUNET_RECLAIM_Handle * GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the re:claimID service.
Definition: reclaim_api.c:1026
struct EgoEntry * next
DLL.
char * url
The url.
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 1049 of file plugin_rest_reclaim.c.

References delete_finished_cb(), do_error(), EgoEntry::ego, RequestHandle::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_RECLAIM_connect(), GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, GNUNET_SCHEDULER_add_now(), GNUNET_STRINGS_string_to_data(), handle, GNUNET_RECLAIM_Attribute::id, id, EgoEntry::identifier, identity, RequestHandle::idp, RequestHandle::idp_op, GNUNET_RECLAIM_Attribute::name, EgoEntry::next, RequestHandle::resp_object, return_response(), and RequestHandle::url.

Referenced by init_cont().

1052 {
1053  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key;
1054  struct RequestHandle *handle = cls;
1055  struct GNUNET_RECLAIM_Attribute attr;
1056  struct EgoEntry *ego_entry;
1057  char *identity_id_str;
1058  char *identity;
1059  char *id;
1060 
1061  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting attributes.\n");
1062  if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) >= strlen (handle->url))
1063  {
1064  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
1066  return;
1067  }
1068  identity_id_str =
1069  strdup (handle->url + strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) + 1);
1070  identity = strtok (identity_id_str, "/");
1071  id = strtok (NULL, "/");
1072  if ((NULL == identity) || (NULL == id))
1073  {
1074  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Malformed request.\n");
1075  GNUNET_free (identity_id_str);
1077  return;
1078  }
1079 
1080  for (ego_entry = handle->ego_head; NULL != ego_entry;
1081  ego_entry = ego_entry->next)
1082  if (0 == strcmp (identity, ego_entry->identifier))
1083  break;
1084  handle->resp_object = json_array ();
1085  if (NULL == ego_entry)
1086  {
1087  // Done
1088  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
1089  GNUNET_free (identity_id_str);
1091  return;
1092  }
1093  priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
1094  handle->idp = GNUNET_RECLAIM_connect (cfg);
1095  memset (&attr, 0, sizeof(struct GNUNET_RECLAIM_Attribute));
1096  GNUNET_STRINGS_string_to_data (id, strlen (id), &attr.id, sizeof(attr.id));
1097  attr.name = "";
1098  handle->idp_op = GNUNET_RECLAIM_attribute_delete (handle->idp,
1099  priv_key,
1100  &attr,
1102  handle);
1103  GNUNET_free (identity_id_str);
1104 }
#define GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES
Attribute namespace.
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_attribute_delete(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const struct GNUNET_RECLAIM_Attribute *attr, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
Delete an attribute.
Definition: reclaim_api.c:1144
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:555
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
Private ECC key encoded for transmission.
The request handle.
The ego list.
struct GNUNET_IDENTITY_Ego * ego
The Ego.
json_t * resp_object
Response object.
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:1298
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration handle.
static void return_response(void *cls)
Return attributes for identity.
struct GNUNET_RECLAIM_Handle * idp
Identity Provider.
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
static void delete_finished_cb(void *cls, int32_t success, const char *emsg)
static void do_error(void *cls)
Task run on error, sends error message.
char * identifier
Ego Identifier.
struct EgoEntry * ego_head
Ego list.
#define GNUNET_log(kind,...)
struct GNUNET_RECLAIM_Operation * idp_op
Idp Operation.
struct GNUNET_RECLAIM_Handle * GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the re:claimID service.
Definition: reclaim_api.c:1026
struct EgoEntry * next
DLL.
int 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:970
#define GNUNET_free(ptr)
Wrapper around free.
char * url
The url.
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 1108 of file plugin_rest_reclaim.c.

References GNUNET_REST_RequestHandle::data, GNUNET_REST_RequestHandle::data_size, do_error(), EgoEntry::ego, RequestHandle::ego_head, RequestHandle::emsg, finished_cont(), GNUNET_ERROR_TYPE_ERROR, 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_connect(), GNUNET_RECLAIM_JSON_spec_ticket(), GNUNET_RECLAIM_ticket_revoke(), GNUNET_SCHEDULER_add_now(), GNUNET_strdup, handle, GNUNET_RECLAIM_Ticket::identity, RequestHandle::idp, RequestHandle::idp_op, EgoEntry::next, RequestHandle::rest_handle, and ticket.

Referenced by init_cont().

1111 {
1112  const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv;
1113  struct RequestHandle *handle = cls;
1114  struct EgoEntry *ego_entry;
1115  struct GNUNET_RECLAIM_Ticket *ticket = NULL;
1116  struct GNUNET_CRYPTO_EcdsaPublicKey tmp_pk;
1117  char term_data[handle->rest_handle->data_size + 1];
1118  json_t *data_json;
1119  json_error_t err;
1120  struct GNUNET_JSON_Specification tktspec[] =
1122 
1123  if (0 >= handle->rest_handle->data_size)
1124  {
1126  return;
1127  }
1128 
1129  term_data[handle->rest_handle->data_size] = '\0';
1130  GNUNET_memcpy (term_data,
1131  handle->rest_handle->data,
1132  handle->rest_handle->data_size);
1133  data_json = json_loads (term_data, JSON_DECODE_ANY, &err);
1134  if ((NULL == data_json) ||
1135  (GNUNET_OK != GNUNET_JSON_parse (data_json, tktspec, NULL, NULL)))
1136  {
1137  handle->emsg = GNUNET_strdup ("Not a ticket!\n");
1139  GNUNET_JSON_parse_free (tktspec);
1140  if (NULL != data_json)
1141  json_decref (data_json);
1142  return;
1143  }
1144  json_decref (data_json);
1145  if (NULL == ticket)
1146  {
1148  "Unable to parse ticket from %s\n",
1149  term_data);
1151  return;
1152  }
1153 
1154  for (ego_entry = handle->ego_head; NULL != ego_entry;
1155  ego_entry = ego_entry->next)
1156  {
1157  GNUNET_IDENTITY_ego_get_public_key (ego_entry->ego, &tmp_pk);
1158  if (0 == memcmp (&ticket->identity,
1159  &tmp_pk,
1160  sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)))
1161  break;
1162  }
1163  if (NULL == ego_entry)
1164  {
1165  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Identity unknown\n");
1166  GNUNET_JSON_parse_free (tktspec);
1167  return;
1168  }
1169  identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
1170 
1171  handle->idp = GNUNET_RECLAIM_connect (cfg);
1172  handle->idp_op = GNUNET_RECLAIM_ticket_revoke (handle->idp,
1173  identity_priv,
1174  ticket,
1175  &finished_cont,
1176  handle);
1177  GNUNET_JSON_parse_free (tktspec);
1178 }
The authorization ticket.
size_t data_size
The POST data size.
void GNUNET_JSON_parse_free(struct GNUNET_JSON_Specification *spec)
Frees all elements allocated during a GNUNET_JSON_parse() operation.
Definition: json.c:100
static void finished_cont(void *cls, int32_t success, const char *emsg)
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:555
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
Entry in parser specification for GNUNET_JSON_parse().
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
Private ECC key encoded for transmission.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
The request handle.
The ego list.
static struct GNUNET_RECLAIM_Ticket ticket
Ticket to consume.
struct GNUNET_IDENTITY_Ego * ego
The Ego.
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_ticket_revoke(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, const struct GNUNET_RECLAIM_Ticket *ticket, GNUNET_RECLAIM_ContinuationWithStatus cb, void *cb_cls)
Revoked an issued ticket.
Definition: reclaim_api.c:1692
char * emsg
Error response message.
int 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:45
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:1298
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration handle.
struct GNUNET_REST_RequestHandle * rest_handle
Rest connection.
const char * data
The POST data.
struct GNUNET_CRYPTO_EcdsaPublicKey identity
The ticket issuer (= the user)
struct GNUNET_RECLAIM_Handle * idp
Identity Provider.
void GNUNET_IDENTITY_ego_get_public_key(const struct GNUNET_IDENTITY_Ego *ego, struct GNUNET_CRYPTO_EcdsaPublicKey *pk)
Get the identifier (public key) of an ego.
Definition: identity_api.c:568
static void do_error(void *cls)
Task run on error, sends error message.
struct EgoEntry * ego_head
Ego list.
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
#define GNUNET_log(kind,...)
struct GNUNET_RECLAIM_Operation * idp_op
Idp Operation.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_end(void)
End of a parser specification.
Definition: json_helper.c:35
struct GNUNET_RECLAIM_Handle * GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the re:claimID service.
Definition: reclaim_api.c:1026
struct EgoEntry * next
DLL.
struct GNUNET_JSON_Specification GNUNET_RECLAIM_JSON_spec_ticket(struct GNUNET_RECLAIM_Ticket **ticket)
JSON Specification for Reclaim tickets.
Definition: json_reclaim.c:268
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_EcdsaPublicKey identity,
const struct GNUNET_RECLAIM_Attribute attr,
const struct GNUNET_RECLAIM_Attestation attest 
)
static

Definition at line 1182 of file plugin_rest_reclaim.c.

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, GNUNET_RECLAIM_Attribute::name, RequestHandle::resp_object, return_response(), GNUNET_RECLAIM_Attribute::type, and value.

Referenced by consume_ticket_cont().

1186 {
1187  struct RequestHandle *handle = cls;
1188  char *val_str;
1189  json_t *value;
1190 
1191  if (NULL == identity)
1192  {
1194  return;
1195  }
1196 
1197  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute: %s\n", attr->name);
1199  attr->data,
1200  attr->data_size);
1201  if (NULL == val_str)
1202  {
1204  "Failed to parse value for: %s\n",
1205  attr->name);
1206  return;
1207  }
1208  value = json_string (val_str);
1209  json_object_set_new (handle->resp_object, attr->name, value);
1210  json_decref (value);
1211  GNUNET_free (val_str);
1212 }
const char * name
The name of the attribute.
The request handle.
json_t * resp_object
Response object.
static char * value
Value of the record to add/remove.
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:1298
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
size_t data_size
Number of bytes in data.
static void return_response(void *cls)
Return attributes for identity.
#define GNUNET_log(kind,...)
const void * data
Binary value stored as attribute value.
char * GNUNET_RECLAIM_attribute_value_to_string(uint32_t type, const void *data, size_t data_size)
Convert the &#39;claim&#39; of an attribute to a string.
uint32_t type
Type of Claim.
#define GNUNET_free(ptr)
Wrapper around free.
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 1216 of file plugin_rest_reclaim.c.

References GNUNET_RECLAIM_Ticket::audience, consume_cont(), GNUNET_REST_RequestHandle::data, GNUNET_REST_RequestHandle::data_size, do_error(), EgoEntry::ego, RequestHandle::ego_head, RequestHandle::emsg, GNUNET_ERROR_TYPE_ERROR, 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_connect(), GNUNET_RECLAIM_JSON_spec_ticket(), GNUNET_RECLAIM_ticket_consume(), GNUNET_SCHEDULER_add_now(), GNUNET_strdup, handle, RequestHandle::idp, RequestHandle::idp_op, EgoEntry::next, RequestHandle::resp_object, RequestHandle::rest_handle, and ticket.

Referenced by init_cont().

1219 {
1220  const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv;
1221  struct RequestHandle *handle = cls;
1222  struct EgoEntry *ego_entry;
1223  struct GNUNET_RECLAIM_Ticket *ticket;
1224  struct GNUNET_CRYPTO_EcdsaPublicKey tmp_pk;
1225  char term_data[handle->rest_handle->data_size + 1];
1226  json_t *data_json;
1227  json_error_t err;
1228  struct GNUNET_JSON_Specification tktspec[] =
1230 
1231  if (0 >= handle->rest_handle->data_size)
1232  {
1234  return;
1235  }
1236 
1237  term_data[handle->rest_handle->data_size] = '\0';
1238  GNUNET_memcpy (term_data,
1239  handle->rest_handle->data,
1240  handle->rest_handle->data_size);
1241  data_json = json_loads (term_data, JSON_DECODE_ANY, &err);
1242  if (NULL == data_json)
1243  {
1245  "Unable to parse JSON Object from %s\n",
1246  term_data);
1248  return;
1249  }
1250  if (GNUNET_OK != GNUNET_JSON_parse (data_json, tktspec, NULL, NULL))
1251  {
1252  handle->emsg = GNUNET_strdup ("Not a ticket!\n");
1254  GNUNET_JSON_parse_free (tktspec);
1255  json_decref (data_json);
1256  return;
1257  }
1258  for (ego_entry = handle->ego_head; NULL != ego_entry;
1259  ego_entry = ego_entry->next)
1260  {
1261  GNUNET_IDENTITY_ego_get_public_key (ego_entry->ego, &tmp_pk);
1262  if (0 == memcmp (&ticket->audience,
1263  &tmp_pk,
1264  sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)))
1265  break;
1266  }
1267  if (NULL == ego_entry)
1268  {
1269  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Identity unknown\n");
1270  GNUNET_JSON_parse_free (tktspec);
1271  return;
1272  }
1273  identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
1274  handle->resp_object = json_object ();
1275  handle->idp = GNUNET_RECLAIM_connect (cfg);
1276  handle->idp_op = GNUNET_RECLAIM_ticket_consume (handle->idp,
1277  identity_priv,
1278  ticket,
1279  &consume_cont,
1280  handle);
1281  GNUNET_JSON_parse_free (tktspec);
1282 }
The authorization ticket.
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_ticket_consume(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, const struct GNUNET_RECLAIM_Ticket *ticket, GNUNET_RECLAIM_AttributeTicketResult cb, void *cb_cls)
Consumes an issued ticket.
Definition: reclaim_api.c:1553
size_t data_size
The POST data size.
void GNUNET_JSON_parse_free(struct GNUNET_JSON_Specification *spec)
Frees all elements allocated during a GNUNET_JSON_parse() operation.
Definition: json.c:100
const struct GNUNET_CRYPTO_EcdsaPrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
Definition: identity_api.c:555
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
Entry in parser specification for GNUNET_JSON_parse().
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:83
Private ECC key encoded for transmission.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
The request handle.
The ego list.
static struct GNUNET_RECLAIM_Ticket ticket
Ticket to consume.
struct GNUNET_IDENTITY_Ego * ego
The Ego.
json_t * resp_object
Response object.
char * emsg
Error response message.
int 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:45
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:1298
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration handle.
struct GNUNET_REST_RequestHandle * rest_handle
Rest connection.
const char * data
The POST data.
struct GNUNET_RECLAIM_Handle * idp
Identity Provider.
void GNUNET_IDENTITY_ego_get_public_key(const struct GNUNET_IDENTITY_Ego *ego, struct GNUNET_CRYPTO_EcdsaPublicKey *pk)
Get the identifier (public key) of an ego.
Definition: identity_api.c:568
static void do_error(void *cls)
Task run on error, sends error message.
struct EgoEntry * ego_head
Ego list.
struct GNUNET_CRYPTO_EcdsaPublicKey audience
The ticket audience (= relying party)
static void consume_cont(void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_Attribute *attr, const struct GNUNET_RECLAIM_Attestation *attest)
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
#define GNUNET_log(kind,...)
struct GNUNET_RECLAIM_Operation * idp_op
Idp Operation.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_end(void)
End of a parser specification.
Definition: json_helper.c:35
struct GNUNET_RECLAIM_Handle * GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the re:claimID service.
Definition: reclaim_api.c:1026
struct EgoEntry * next
DLL.
struct GNUNET_JSON_Specification GNUNET_RECLAIM_JSON_spec_ticket(struct GNUNET_RECLAIM_Ticket **ticket)
JSON Specification for Reclaim tickets.
Definition: json_reclaim.c:268
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 1293 of file plugin_rest_reclaim.c.

References allow_methods, cleanup_handle(), GNUNET_REST_create_response(), handle, RequestHandle::proc, and RequestHandle::proc_cls.

Referenced by init_cont().

1296 {
1297  struct MHD_Response *resp;
1298  struct RequestHandle *handle = cls;
1299 
1300  // For now, independent of path return all options
1301  resp = GNUNET_REST_create_response (NULL);
1302  MHD_add_response_header (resp, "Access-Control-Allow-Methods", allow_methods);
1303  handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
1304  cleanup_handle (handle);
1305  return;
1306 }
GNUNET_REST_ResultProcessor proc
The plugin result processor.
void * proc_cls
The closure of the result processor.
The request handle.
static char * allow_methods
HTTP methods allows for this plugin.
static void cleanup_handle(struct RequestHandle *handle)
Cleanup lookup handle.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
struct MHD_Response * GNUNET_REST_create_response(const char *data)
Create REST MHD response.
Definition: rest.c:57
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_cont()

static void init_cont ( struct RequestHandle handle)
static

Handle rest request.

Parameters
handlethe request handle

Definition at line 1315 of file plugin_rest_reclaim.c.

References add_attestation_cont(), add_attribute_cont(), consume_ticket_cont(), delete_attestation_cont(), delete_attribute_cont(), do_error(), GNUNET_REST_RequestHandlerError::error_code, 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_ATTESTATION, GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, GNUNET_REST_handle_request(), GNUNET_REST_HANDLER_END, GNUNET_SCHEDULER_add_now(), list_attestation_cont(), list_attribute_cont(), list_tickets_cont(), options_cont(), RequestHandle::response_code, RequestHandle::rest_handle, and revoke_ticket_cont().

Referenced by list_ego().

1316 {
1318  static const struct GNUNET_REST_RequestHandler handlers[] =
1319  { { MHD_HTTP_METHOD_GET,
1322  { MHD_HTTP_METHOD_POST,
1324  &add_attribute_cont },
1325  { MHD_HTTP_METHOD_DELETE,
1328  { MHD_HTTP_METHOD_GET,
1331  { MHD_HTTP_METHOD_POST,
1334  { MHD_HTTP_METHOD_DELETE,
1337  { MHD_HTTP_METHOD_GET,
1339  &list_tickets_cont },
1340  { MHD_HTTP_METHOD_POST,
1342  &revoke_ticket_cont },
1343  { MHD_HTTP_METHOD_POST,
1346  { MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_RECLAIM, &options_cont },
1348 
1349  if (GNUNET_NO ==
1350  GNUNET_REST_handle_request (handle->rest_handle, handlers, &err, handle))
1351  {
1352  handle->response_code = err.error_code;
1354  }
1355 }
static void list_attribute_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
List attributes for identity request.
#define GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES
Attribute namespace.
static void consume_ticket_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)
#define GNUNET_REST_API_NS_IDENTITY_CONSUME
Revoke namespace.
#define GNUNET_NO
Definition: gnunet_common.h:86
static void add_attestation_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.
#define GNUNET_REST_HANDLER_END
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
#define GNUNET_REST_API_NS_RECLAIM_ATTESTATION
Attestation namespace.
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:1298
static void list_tickets_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
List tickets for identity request.
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:77
struct GNUNET_REST_RequestHandle * rest_handle
Rest connection.
int response_code
Response code.
#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.
#define GNUNET_REST_API_NS_IDENTITY_REVOKE
Revoke namespace.
static void delete_attestation_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
Deletes attestation from an identity.
static void do_error(void *cls)
Task run on error, sends error message.
static void list_attestation_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
Lists attestation for identity request.
static void revoke_ticket_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
#define GNUNET_REST_API_NS_IDENTITY_TICKETS
Ticket namespace.
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 (i.e. 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 1392 of file plugin_rest_reclaim.c.

References EgoEntry::ego, RequestHandle::ego_head, RequestHandle::ego_tail, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_CRYPTO_ecdsa_public_key_to_string(), GNUNET_IDENTITY_ego_get_public_key(), GNUNET_new, GNUNET_strdup, handle, ID_REST_STATE_INIT, ID_REST_STATE_POST_INIT, EgoEntry::identifier, init_cont(), EgoEntry::keystring, and RequestHandle::state.

Referenced by rest_identity_process_request().

1396 {
1397  struct RequestHandle *handle = cls;
1398  struct EgoEntry *ego_entry;
1400 
1401  if ((NULL == ego) && (ID_REST_STATE_INIT == handle->state))
1402  {
1403  handle->state = ID_REST_STATE_POST_INIT;
1404  init_cont (handle);
1405  return;
1406  }
1407  if (ID_REST_STATE_INIT == handle->state)
1408  {
1409  ego_entry = GNUNET_new (struct EgoEntry);
1412  ego_entry->ego = ego;
1413  ego_entry->identifier = GNUNET_strdup (identifier);
1415  handle->ego_tail,
1416  ego_entry);
1417  }
1418 }
static struct GNUNET_CRYPTO_EddsaPrivateKey * pk
Private key of this peer.
struct EgoEntry * ego_tail
Ego list.
static void init_cont(struct RequestHandle *handle)
Handle rest request.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
The request handle.
The ego list.
struct GNUNET_IDENTITY_Ego * ego
The Ego.
#define ID_REST_STATE_INIT
State while collecting all egos.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
#define ID_REST_STATE_POST_INIT
Done collecting egos.
int state
The processing state.
char * GNUNET_CRYPTO_ecdsa_public_key_to_string(const struct GNUNET_CRYPTO_EcdsaPublicKey *pub)
Convert a public key to a string.
Definition: crypto_ecc.c:223
char * keystring
Public key string.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
void GNUNET_IDENTITY_ego_get_public_key(const struct GNUNET_IDENTITY_Ego *ego, struct GNUNET_CRYPTO_EcdsaPublicKey *pk)
Get the identifier (public key) of an ego.
Definition: identity_api.c:568
char * identifier
Ego Identifier.
struct EgoEntry * ego_head
Ego list.
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rest_identity_process_request()

static void rest_identity_process_request ( struct GNUNET_REST_RequestHandle rest_handle,
GNUNET_REST_ResultProcessor  proc,
void *  proc_cls 
)
static

Definition at line 1422 of file plugin_rest_reclaim.c.

References do_timeout(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_IDENTITY_connect(), GNUNET_log, GNUNET_new, GNUNET_SCHEDULER_add_delayed(), GNUNET_strdup, GNUNET_TIME_UNIT_FOREVER_REL, handle, ID_REST_STATE_INIT, RequestHandle::identity_handle, list_ego(), RequestHandle::proc, RequestHandle::proc_cls, RequestHandle::response_code, RequestHandle::rest_handle, RequestHandle::state, RequestHandle::timeout, RequestHandle::timeout_task, GNUNET_REST_RequestHandle::url, and RequestHandle::url.

Referenced by libgnunet_plugin_rest_reclaim_init().

1425 {
1426  struct RequestHandle *handle = GNUNET_new (struct RequestHandle);
1427 
1428  handle->response_code = 0;
1430  handle->proc_cls = proc_cls;
1431  handle->proc = proc;
1432  handle->state = ID_REST_STATE_INIT;
1433  handle->rest_handle = rest_handle;
1434 
1435  handle->url = GNUNET_strdup (rest_handle->url);
1436  if (handle->url[strlen (handle->url) - 1] == '/')
1437  handle->url[strlen (handle->url) - 1] = '\0';
1438  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting...\n");
1439  handle->identity_handle = GNUNET_IDENTITY_connect (cfg, &list_ego, handle);
1440  handle->timeout_task =
1441  GNUNET_SCHEDULER_add_delayed (handle->timeout, &do_timeout, handle);
1442  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected\n");
1443 }
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:527
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.
GNUNET_REST_ResultProcessor proc
The plugin result processor.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
void * proc_cls
The closure of the result processor.
The request handle.
#define ID_REST_STATE_INIT
State while collecting all egos.
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:1271
const char * url
The url as string.
struct GNUNET_TIME_Relative timeout
Desired timeout for the lookup (default is no timeout).
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration handle.
struct GNUNET_REST_RequestHandle * rest_handle
Rest connection.
int response_code
Response code.
int state
The processing state.
struct GNUNET_SCHEDULER_Task * timeout_task
ID of a task associated with the resolution process.
static void do_timeout(void *cls)
Task run on timeout, sends error message.
#define GNUNET_log(kind,...)
struct GNUNET_IDENTITY_Handle * identity_handle
Handle to Identity service.
char * url
The url.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ libgnunet_plugin_rest_reclaim_init()

void* libgnunet_plugin_rest_reclaim_init ( void *  cls)

Entry point for the plugin.

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

Definition at line 1453 of file plugin_rest_reclaim.c.

References _, allow_methods, Plugin::api, Plugin::cfg, GNUNET_REST_Plugin::cls, GNUNET_asprintf(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, GNUNET_REST_API_NS_RECLAIM, GNUNET_REST_Plugin::name, plugin, GNUNET_REST_Plugin::process_request, and rest_identity_process_request().

1454 {
1455  static struct Plugin plugin;
1456  struct GNUNET_REST_Plugin *api;
1457 
1458  cfg = cls;
1459  if (NULL != plugin.cfg)
1460  return NULL; /* can only initialize once! */
1461  memset (&plugin, 0, sizeof(struct Plugin));
1462  plugin.cfg = cfg;
1463  api = GNUNET_new (struct GNUNET_REST_Plugin);
1464  api->cls = &plugin;
1468  "%s, %s, %s, %s, %s",
1469  MHD_HTTP_METHOD_GET,
1470  MHD_HTTP_METHOD_POST,
1471  MHD_HTTP_METHOD_PUT,
1472  MHD_HTTP_METHOD_DELETE,
1473  MHD_HTTP_METHOD_OPTIONS);
1474 
1476  _ ("Identity Provider REST API initialized\n"));
1477  return api;
1478 }
void * cls
The closure of the plugin.
struct returned by the initialization function of the plugin
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void(* process_request)(struct GNUNET_REST_RequestHandle *handle, GNUNET_REST_ResultProcessor proc, void *proc_cls)
Function to process a REST call.
#define _(String)
GNU gettext support macro.
Definition: platform.h:180
static void rest_identity_process_request(struct GNUNET_REST_RequestHandle *rest_handle, GNUNET_REST_ResultProcessor proc, void *proc_cls)
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
static char * allow_methods
HTTP methods allows for this plugin.
char * name
Plugin name.
const struct GNUNET_CONFIGURATION_Handle * cfg
The configuration handle.
#define GNUNET_REST_API_NS_RECLAIM
REST root namespace.
static char * plugin
Solver plugin name as string.
Handle for a plugin.
Definition: block.c:37
#define GNUNET_log(kind,...)
Here is the call graph for this function:

◆ libgnunet_plugin_rest_reclaim_done()

void* libgnunet_plugin_rest_reclaim_done ( void *  cls)

Exit point from the plugin.

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

Definition at line 1488 of file plugin_rest_reclaim.c.

References allow_methods, Plugin::api, Plugin::cfg, GNUNET_REST_Plugin::cls, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_free_non_null, GNUNET_log, and plugin.

1489 {
1490  struct GNUNET_REST_Plugin *api = cls;
1491  struct Plugin *plugin = api->cls;
1492 
1493  plugin->cfg = NULL;
1494 
1496  GNUNET_free (api);
1498  "Identity Provider REST plugin is finished\n");
1499  return NULL;
1500 }
void * cls
The closure of the plugin.
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
struct returned by the initialization function of the plugin
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
static char * allow_methods
HTTP methods allows for this plugin.
static char * plugin
Solver plugin name as string.
Handle for a plugin.
Definition: block.c:37
#define GNUNET_log(kind,...)
#define GNUNET_free(ptr)
Wrapper around free.

Variable Documentation

◆ cfg

const struct GNUNET_CONFIGURATION_Handle* cfg

The configuration handle.

Handle to our configuration.

Definition at line 83 of file plugin_rest_reclaim.c.

◆ allow_methods

char* allow_methods
static

HTTP methods allows for this plugin.

Definition at line 88 of file plugin_rest_reclaim.c.

Referenced by libgnunet_plugin_rest_reclaim_done(), libgnunet_plugin_rest_reclaim_init(), and options_cont().