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_CREDENTIAL   "/reclaim/credential"
 Credential namespace. More...
 
#define GNUNET_REST_API_NS_IDENTITY_TICKETS   "/reclaim/tickets"
 Ticket namespace. More...
 
#define GNUNET_REST_API_NS_IDENTITY_REVOKE   "/reclaim/revoke"
 Revoke namespace. More...
 
#define GNUNET_REST_API_NS_IDENTITY_CONSUME   "/reclaim/consume"
 Revoke namespace. More...
 
#define ID_REST_STATE_INIT   0
 State while collecting all egos. More...
 
#define ID_REST_STATE_POST_INIT   1
 Done collecting egos. More...
 

Functions

static void cleanup_handle (void *cls)
 Cleanup lookup handle. More...
 
static void do_error (void *cls)
 Task run on error, sends error message. More...
 
static void do_timeout (void *cls)
 Task run on timeout, sends error message. More...
 
static void collect_error_cb (void *cls)
 
static void finished_cont (void *cls, int32_t success, const char *emsg)
 
static void delete_finished_cb (void *cls, int32_t success, const char *emsg)
 
static void return_response (void *cls)
 Return attributes for identity. More...
 
static void collect_finished_cb (void *cls)
 
static void ticket_collect (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket)
 Collect all attributes for an ego. More...
 
static void add_credential_cont (struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
 
static void cred_collect (void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_Credential *cred)
 Collect all credentials for an ego. More...
 
static void list_credential_cont (struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
 Lists credential for identity request. More...
 
static void delete_credential_cont (struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
 Deletes credential from an identity. More...
 
static void list_tickets_cont (struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
 List tickets for identity request. More...
 
static void add_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
 
struct GNUNET_RECLAIM_Attributeparse_jwt (const struct GNUNET_RECLAIM_Credential *cred, const char *claim)
 Parse a JWT and return the respective claim value as Attribute. More...
 
static void attr_collect (void *cls, const struct GNUNET_CRYPTO_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_Presentation *pres)
 
static void consume_ticket_cont (struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
 
static void options_cont (struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
 Respond to OPTIONS request. More...
 
static void list_ego (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, const char *identifier)
 If listing is enabled, prints information about the egos. More...
 
static enum GNUNET_GenericReturnValue 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...
 
static struct EgoEntryego_head
 Ego list. More...
 
static struct EgoEntryego_tail
 Ego list. More...
 
static int state
 The processing state. More...
 
static struct GNUNET_IDENTITY_Handleidentity_handle
 Handle to Identity service. More...
 
static struct GNUNET_RECLAIM_Handleidp
 Identity Provider. More...
 
static struct RequestHandlerequests_head
 DLL. More...
 
static struct RequestHandlerequests_tail
 DLL. More...
 

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 libgnunet_plugin_rest_reclaim_init(), and rest_identity_process_request().

◆ GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES

#define GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES   "/reclaim/attributes"

◆ GNUNET_REST_API_NS_RECLAIM_CREDENTIAL

#define GNUNET_REST_API_NS_RECLAIM_CREDENTIAL   "/reclaim/credential"

◆ 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 list_tickets_cont(), and rest_identity_process_request().

◆ 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 rest_identity_process_request().

◆ 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 rest_identity_process_request().

◆ 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 libgnunet_plugin_rest_reclaim_init(), and list_ego().

◆ 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 ( void *  cls)
static

Cleanup lookup handle.

Parameters
handleHandle to clean up

Definition at line 274 of file plugin_rest_reclaim.c.

References RequestHandle::attr_it, RequestHandle::attr_list, RequestHandle::cred_it, RequestHandle::emsg, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_RECLAIM_attribute_list_destroy(), GNUNET_RECLAIM_get_attributes_stop(), GNUNET_RECLAIM_get_credentials_stop(), GNUNET_RECLAIM_ticket_iteration_stop(), GNUNET_SCHEDULER_cancel(), handle, RequestHandle::resp_object, RequestHandle::ticket_it, RequestHandle::timeout_task, and RequestHandle::url.

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

275 {
276  struct RequestHandle *handle = cls;
277 
278  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n");
279  if (NULL != handle->resp_object)
280  json_decref (handle->resp_object);
281  if (NULL != handle->timeout_task)
283  if (NULL != handle->attr_it)
285  if (NULL != handle->cred_it)
287  if (NULL != handle->ticket_it)
289  if (NULL != handle->url)
290  GNUNET_free (handle->url);
291  if (NULL != handle->emsg)
292  GNUNET_free (handle->emsg);
293  if (NULL != handle->attr_list)
297  handle);
298  GNUNET_free (handle);
299 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
void GNUNET_RECLAIM_get_credentials_stop(struct GNUNET_RECLAIM_CredentialIterator *ait)
Stops iteration and releases the handle for further calls.
Definition: reclaim_api.c:1509
void GNUNET_RECLAIM_attribute_list_destroy(struct GNUNET_RECLAIM_AttributeList *attrs)
Destroy claim list.
struct GNUNET_RECLAIM_AttributeIterator * attr_it
Attribute iterator.
void GNUNET_RECLAIM_ticket_iteration_stop(struct GNUNET_RECLAIM_TicketIterator *it)
Stops iteration and releases the handle for further calls.
Definition: reclaim_api.c:1701
The request handle.
json_t * resp_object
Response object.
char * emsg
Error response message.
static struct RequestHandle * requests_tail
DLL.
struct GNUNET_RECLAIM_TicketIterator * ticket_it
Ticket iterator.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
struct GNUNET_RECLAIM_AttributeList * attr_list
Attribute claim list.
struct GNUNET_RECLAIM_CredentialIterator * cred_it
Credential iterator.
void GNUNET_RECLAIM_get_attributes_stop(struct GNUNET_RECLAIM_AttributeIterator *it)
Stops iteration and releases the handle for further calls.
Definition: reclaim_api.c:1398
struct GNUNET_SCHEDULER_Task * timeout_task
ID of a task associated with the resolution process.
static struct RequestHandle * requests_head
DLL.
#define GNUNET_log(kind,...)
#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:972
char * url
The url.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ do_error()

static void do_error ( void *  cls)
static

Task run on error, sends error message.

Cleans up everything.

Parameters
clsthe struct RequestHandle

Definition at line 308 of file plugin_rest_reclaim.c.

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

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

309 {
310  struct RequestHandle *handle = cls;
311  struct MHD_Response *resp;
312  char *json_error;
313 
314  GNUNET_asprintf (&json_error, "{ \"error\" : \"%s\" }", handle->emsg);
315  if (0 == handle->response_code)
316  {
317  handle->response_code = MHD_HTTP_BAD_REQUEST;
318  }
319  resp = GNUNET_REST_create_response (json_error);
320  MHD_add_response_header (resp, "Content-Type", "application/json");
321  handle->proc (handle->proc_cls, resp, handle->response_code);
322  cleanup_handle (handle);
323  GNUNET_free (json_error);
324 }
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.
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
static void cleanup_handle(void *cls)
Cleanup lookup handle.
#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 333 of file plugin_rest_reclaim.c.

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

Referenced by rest_identity_process_request().

334 {
335  struct RequestHandle *handle = cls;
336 
337  handle->timeout_task = NULL;
338  do_error (handle);
339 }
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 343 of file plugin_rest_reclaim.c.

References do_error(), and GNUNET_SCHEDULER_add_now().

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

344 {
346 }
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:1296
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 350 of file plugin_rest_reclaim.c.

References allow_methods, cleanup_handle(), do_error(), GNUNET_OK, GNUNET_REST_create_response(), GNUNET_SCHEDULER_add_now(), handle, RequestHandle::idp_op, RequestHandle::proc, and RequestHandle::proc_cls.

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

351 {
352  struct RequestHandle *handle = cls;
353  struct MHD_Response *resp;
354 
355  handle->idp_op = NULL;
356  resp = GNUNET_REST_create_response (emsg);
357  MHD_add_response_header (resp, "Content-Type", "application/json");
358  MHD_add_response_header (resp, "Access-Control-Allow-Methods", allow_methods);
359  if (GNUNET_OK != success)
360  {
362  return;
363  }
364  handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
366 }
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.
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:1296
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
struct GNUNET_RECLAIM_Operation * idp_op
Idp Operation.
static void cleanup_handle(void *cls)
Cleanup lookup handle.
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 370 of file plugin_rest_reclaim.c.

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

Referenced by delete_attribute_cont(), and delete_credential_cont().

371 {
372  struct RequestHandle *handle = cls;
373  struct MHD_Response *resp;
374 
375  resp = GNUNET_REST_create_response (emsg);
376  MHD_add_response_header (resp, "Access-Control-Allow-Methods", allow_methods);
377  if (GNUNET_OK != success)
378  {
380  return;
381  }
382  handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
384 }
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.
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:1296
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
static void cleanup_handle(void *cls)
Cleanup lookup handle.
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 393 of file plugin_rest_reclaim.c.

References allow_methods, 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_attribute_cont(), delete_credential_cont(), list_attribute_cont(), list_credential_cont(), and list_tickets_cont().

394 {
395  char *result_str;
396  struct RequestHandle *handle = cls;
397  struct MHD_Response *resp;
398 
399  result_str = json_dumps (handle->resp_object, 0);
400  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str);
401  resp = GNUNET_REST_create_response (result_str);
402  MHD_add_response_header (resp, "Access-Control-Allow-Methods", allow_methods);
403  handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
404  GNUNET_free (result_str);
405  cleanup_handle (handle);
406 }
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.
json_t * resp_object
Response object.
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,...)
static void cleanup_handle(void *cls)
Cleanup lookup handle.
#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 410 of file plugin_rest_reclaim.c.

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

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

411 {
412  struct RequestHandle *handle = cls;
413 
414  // Done
415  handle->attr_it = NULL;
416  handle->cred_it = NULL;
417  handle->ticket_it = NULL;
419 }
struct GNUNET_RECLAIM_AttributeIterator * attr_it
Attribute 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:1296
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.
struct GNUNET_RECLAIM_CredentialIterator * cred_it
Credential iterator.
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 427 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().

428 {
429  json_t *json_resource;
430  struct RequestHandle *handle = cls;
431  json_t *value;
432  char *tmp;
433 
434  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding ticket\n");
435  tmp = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof(ticket->rnd));
436  json_resource = json_object ();
437  GNUNET_free (tmp);
438  json_array_append (handle->resp_object, json_resource);
439 
440  tmp =
442  sizeof(struct
444  value = json_string (tmp);
445  json_object_set_new (json_resource, "issuer", value);
446  GNUNET_free (tmp);
447  tmp =
449  sizeof(struct
451  value = json_string (tmp);
452  json_object_set_new (json_resource, "audience", value);
453  GNUNET_free (tmp);
454  tmp = GNUNET_STRINGS_data_to_string_alloc (&ticket->rnd, sizeof(ticket->rnd));
455  value = json_string (tmp);
456  json_object_set_new (json_resource, "rnd", value);
457  GNUNET_free (tmp);
459 }
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:1681
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:936
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_credential_cont()

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

New ID for attribute

Definition at line 463 of file plugin_rest_reclaim.c.

References GNUNET_REST_RequestHandle::data, GNUNET_REST_RequestHandle::data_size, do_error(), EgoEntry::ego, finished_cont(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_IDENTITY_ego_get_private_key(), GNUNET_JSON_parse(), GNUNET_JSON_parse_free(), GNUNET_JSON_spec_end(), GNUNET_log, GNUNET_memcpy, GNUNET_RECLAIM_credential_store(), GNUNET_RECLAIM_id_generate, GNUNET_RECLAIM_id_is_zero, GNUNET_RECLAIM_JSON_spec_credential(), GNUNET_REST_API_NS_RECLAIM_CREDENTIAL, GNUNET_SCHEDULER_add_now(), GNUNET_TIME_UNIT_HOURS, GNUNET_YES, handle, GNUNET_RECLAIM_Credential::id, EgoEntry::identifier, identity, RequestHandle::idp_op, EgoEntry::next, RequestHandle::rest_handle, and RequestHandle::url.

Referenced by rest_identity_process_request().

466 {
467  struct RequestHandle *handle = cls;
468  const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv;
469  const char *identity;
470  struct EgoEntry *ego_entry;
471  struct GNUNET_RECLAIM_Credential *attribute;
472  struct GNUNET_TIME_Relative exp;
473  char term_data[handle->rest_handle->data_size + 1];
474  json_t *data_json;
475  json_error_t err;
476  struct GNUNET_JSON_Specification attrspec[] =
479 
481  "Adding an credential for %s.\n",
482  handle->url);
483  if (strlen (GNUNET_REST_API_NS_RECLAIM_CREDENTIAL) >= strlen (
484  handle->url))
485  {
486  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
488  return;
489  }
490  identity = handle->url + strlen (
492 
493  for (ego_entry = ego_head; NULL != ego_entry;
494  ego_entry = ego_entry->next)
495  if (0 == strcmp (identity, ego_entry->identifier))
496  break;
497 
498  if (NULL == ego_entry)
499  {
500  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Identity unknown (%s)\n", identity);
501  return;
502  }
503  identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
504 
505  if (0 >= handle->rest_handle->data_size)
506  {
508  return;
509  }
510 
511  term_data[handle->rest_handle->data_size] = '\0';
512  GNUNET_memcpy (term_data,
513  handle->rest_handle->data,
514  handle->rest_handle->data_size);
515  data_json = json_loads (term_data, JSON_DECODE_ANY, &err);
516  GNUNET_JSON_parse (data_json, attrspec, NULL, NULL);
517  json_decref (data_json);
518  if (NULL == attribute)
519  {
521  "Unable to parse credential from %s\n",
522  term_data);
524  return;
525  }
529  if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&attribute->id))
530  GNUNET_RECLAIM_id_generate (&attribute->id);
533  identity_priv,
534  attribute,
535  &exp,
536  &finished_cont,
537  handle);
538  GNUNET_JSON_parse_free (attrspec);
539 }
#define GNUNET_TIME_UNIT_HOURS
One hour.
struct GNUNET_RECLAIM_Identifier id
ID.
size_t data_size
The POST data size.
enum GNUNET_GenericReturnValue GNUNET_JSON_parse(const json_t *root, struct GNUNET_JSON_Specification *spec, const char **error_json_name, unsigned int *error_line)
Navigate and parse data in a JSON tree.
Definition: json.c:45
#define GNUNET_REST_API_NS_RECLAIM_CREDENTIAL
Credential namespace.
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:595
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
Entry in parser specification for GNUNET_JSON_parse().
Private ECC key encoded for transmission.
struct GNUNET_JSON_Specification GNUNET_RECLAIM_JSON_spec_credential(struct GNUNET_RECLAIM_Credential **cred)
JSON Specification for credential claims.
Definition: json_reclaim.c:379
The request handle.
The ego list.
struct GNUNET_IDENTITY_Ego * ego
The Ego.
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:1296
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
struct GNUNET_REST_RequestHandle * rest_handle
Rest connection.
const char * data
The POST data.
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 struct EgoEntry * ego_head
Ego list.
#define GNUNET_log(kind,...)
struct GNUNET_RECLAIM_Operation * idp_op
Idp Operation.
static struct GNUNET_RECLAIM_Handle * idp
Identity Provider.
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_credential_store(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const struct GNUNET_RECLAIM_Credential *credential, const struct GNUNET_TIME_Relative *exp_interval, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
Store a credential.
Definition: reclaim_api.c:1227
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 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:

◆ cred_collect()

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

Collect all credentials for an ego.

Definition at line 547 of file plugin_rest_reclaim.c.

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

Referenced by list_credential_cont().

550 {
551  struct RequestHandle *handle = cls;
552  struct GNUNET_RECLAIM_AttributeList *attrs;
554  struct GNUNET_TIME_Absolute exp;
555  json_t *attr_obj;
556  json_t *cred_obj;
557  const char *type;
558  char *tmp_value;
559  char *id_str;
560  char *issuer;
561 
562 
563  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding credential: %s\n",
564  cred->name);
566  issuer = GNUNET_RECLAIM_credential_get_issuer (cred);
568  cred->data,
569  cred->data_size);
570  cred_obj = json_object ();
571  json_object_set_new (cred_obj, "value", json_string (tmp_value));
572  json_object_set_new (cred_obj, "name", json_string (cred->name));
574  json_object_set_new (cred_obj, "type", json_string (type));
575  if (NULL != issuer)
576  {
577  json_object_set_new (cred_obj, "issuer", json_string (issuer));
578  GNUNET_free (issuer);
579  }
581  &exp))
582  {
583  json_object_set_new (cred_obj, "expiration", json_integer (
584  exp.abs_value_us));
585  }
586  id_str = GNUNET_STRINGS_data_to_string_alloc (&cred->id,
587  sizeof(cred->id));
588  json_object_set_new (cred_obj, "id", json_string (id_str));
589  GNUNET_free (tmp_value);
590  GNUNET_free (id_str);
591  if (NULL != attrs)
592  {
593  json_t *attr_arr = json_array ();
594  for (ale = attrs->list_head; NULL != ale; ale = ale->next)
595  {
596  tmp_value =
598  ale->attribute->data,
599  ale->attribute->data_size);
600  attr_obj = json_object ();
601  json_object_set_new (attr_obj, "value", json_string (tmp_value));
602  json_object_set_new (attr_obj, "name", json_string (
603  ale->attribute->name));
604 
605  json_object_set_new (attr_obj, "flag", json_string ("1")); // FIXME
607  json_object_set_new (attr_obj, "type", json_string (type));
608  json_object_set_new (attr_obj, "id", json_string (""));
609  json_object_set_new (attr_obj, "credential", json_string (""));
610  json_array_append_new (attr_arr, attr_obj);
611  GNUNET_free (tmp_value);
612  }
613  json_object_set_new (cred_obj, "attributes", attr_arr);
614  }
615  json_array_append_new (handle->resp_object, cred_obj);
618 }
void GNUNET_RECLAIM_get_credentials_next(struct GNUNET_RECLAIM_CredentialIterator *ait)
Calls the record processor specified in GNUNET_RECLAIM_get_credentials_start for the next record...
Definition: reclaim_api.c:1487
struct GNUNET_RECLAIM_Identifier id
ID.
uint32_t type
Type/Format of Claim.
void GNUNET_RECLAIM_attribute_list_destroy(struct GNUNET_RECLAIM_AttributeList *attrs)
Destroy claim list.
const char * name
The name of the attribute.
int GNUNET_RECLAIM_credential_get_expiration(const struct GNUNET_RECLAIM_Credential *cred, struct GNUNET_TIME_Absolute *exp)
size_t data_size
Number of bytes in data.
A list of GNUNET_RECLAIM_Attribute structures.
const void * data
Binary value stored as credential value.
struct GNUNET_RECLAIM_Attribute * attribute
The attribute claim.
The request handle.
const char * GNUNET_RECLAIM_credential_number_to_typename(uint32_t type)
Convert an credential type number to the corresponding credential type string.
char * GNUNET_RECLAIM_credential_get_issuer(const struct GNUNET_RECLAIM_Credential *cred)
json_t * resp_object
Response object.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
size_t data_size
Number of bytes in data.
const char * name
The name of the credential.
struct GNUNET_RECLAIM_AttributeListEntry * next
DLL.
struct GNUNET_RECLAIM_CredentialIterator * cred_it
Credential iterator.
const char * GNUNET_RECLAIM_attribute_number_to_typename(uint32_t type)
Convert a type number to the corresponding type string.
#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.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
Time for absolute times used by GNUnet, in microseconds.
char * GNUNET_RECLAIM_credential_value_to_string(uint32_t type, const void *data, size_t data_size)
Convert the &#39;claim&#39; of an credential to a string.
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:936
struct GNUNET_RECLAIM_AttributeListEntry * list_head
List head.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_RECLAIM_AttributeList * GNUNET_RECLAIM_credential_get_attributes(const struct GNUNET_RECLAIM_Credential *cred)
Convert an credential type name to the corresponding number.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ list_credential_cont()

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

Lists credential for identity request.

Parameters
con_handlethe connection handle
urlthe url
clsthe RequestHandle

Definition at line 629 of file plugin_rest_reclaim.c.

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

Referenced by rest_identity_process_request().

632 {
633  struct RequestHandle *handle = cls;
634  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key;
635  struct EgoEntry *ego_entry;
636  char *identity;
637 
639  "Getting credentials for %s.\n",
640  handle->url);
641  if (strlen (GNUNET_REST_API_NS_RECLAIM_CREDENTIAL) >= strlen (
642  handle->url))
643  {
644  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
646  return;
647  }
648  identity = handle->url + strlen (
650 
651  for (ego_entry = ego_head; NULL != ego_entry;
652  ego_entry = ego_entry->next)
653  if (0 == strcmp (identity, ego_entry->identifier))
654  break;
655  handle->resp_object = json_array ();
656 
657 
658  if (NULL == ego_entry)
659  {
660  // Done
661  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
663  return;
664  }
665  priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
667  priv_key,
669  handle,
670  &cred_collect,
671  handle,
672  &
674  handle);
675 }
static void collect_error_cb(void *cls)
#define GNUNET_REST_API_NS_RECLAIM_CREDENTIAL
Credential namespace.
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:595
Private ECC key encoded for transmission.
struct GNUNET_RECLAIM_CredentialIterator * GNUNET_RECLAIM_get_credentials_start(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_RECLAIM_CredentialResult proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
List all credentials for a local identity.
Definition: reclaim_api.c:1440
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:1296
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
static void return_response(void *cls)
Return attributes for identity.
static struct GNUNET_IDENTITY_Handle * identity
Which namespace do we publish to? NULL if we do not publish to a namespace.
struct GNUNET_RECLAIM_CredentialIterator * cred_it
Credential iterator.
static void do_error(void *cls)
Task run on error, sends error message.
char * identifier
Ego Identifier.
static struct EgoEntry * ego_head
Ego list.
static void cred_collect(void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_Credential *cred)
Collect all credentials for an ego.
#define GNUNET_log(kind,...)
static struct GNUNET_RECLAIM_Handle * idp
Identity Provider.
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_credential_cont()

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

Deletes credential from an identity.

Parameters
con_handlethe connection handle
urlthe url
clsthe RequestHandle

Definition at line 686 of file plugin_rest_reclaim.c.

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

Referenced by rest_identity_process_request().

689 {
690  struct RequestHandle *handle = cls;
691  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key;
692  struct GNUNET_RECLAIM_Credential attr;
693  struct EgoEntry *ego_entry;
694  char *identity_id_str;
695  char *identity;
696  char *id;
697 
698  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleting credential.\n");
699  if (strlen (GNUNET_REST_API_NS_RECLAIM_CREDENTIAL) >= strlen (
700  handle->url))
701  {
702  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
704  return;
705  }
706  identity_id_str =
707  strdup (handle->url + strlen (
709  identity = strtok (identity_id_str, "/");
710  id = strtok (NULL, "/");
711  if ((NULL == identity) || (NULL == id))
712  {
713  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Malformed request.\n");
714  GNUNET_free (identity_id_str);
716  return;
717  }
718 
719  for (ego_entry = ego_head; NULL != ego_entry;
720  ego_entry = ego_entry->next)
721  if (0 == strcmp (identity, ego_entry->identifier))
722  break;
723  handle->resp_object = json_array ();
724  if (NULL == ego_entry)
725  {
726  // Done
727  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
728  GNUNET_free (identity_id_str);
730  return;
731  }
732  priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
733  memset (&attr, 0, sizeof(struct GNUNET_RECLAIM_Credential));
734  GNUNET_STRINGS_string_to_data (id, strlen (id), &attr.id, sizeof(attr.id));
735  attr.name = "";
737  priv_key,
738  &attr,
740  handle);
741  GNUNET_free (identity_id_str);
742 }
#define GNUNET_REST_API_NS_RECLAIM_CREDENTIAL
Credential namespace.
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:595
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:1296
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
static void return_response(void *cls)
Return attributes for identity.
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.
static struct EgoEntry * ego_head
Ego list.
#define GNUNET_log(kind,...)
struct GNUNET_RECLAIM_Operation * idp_op
Idp Operation.
static struct GNUNET_RECLAIM_Handle * idp
Identity Provider.
struct GNUNET_RECLAIM_Operation * GNUNET_RECLAIM_credential_delete(struct GNUNET_RECLAIM_Handle *h, const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, const struct GNUNET_RECLAIM_Credential *cred, GNUNET_RECLAIM_ContinuationWithStatus cont, void *cont_cls)
Delete a credential.
Definition: reclaim_api.c:1274
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:971
#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 753 of file plugin_rest_reclaim.c.

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

Referenced by rest_identity_process_request().

756 {
757  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key;
758  struct RequestHandle *handle = cls;
759  struct EgoEntry *ego_entry;
760  char *identity;
761 
763  "Getting tickets for %s.\n",
764  handle->url);
765  if (strlen (GNUNET_REST_API_NS_IDENTITY_TICKETS) >= strlen (handle->url))
766  {
767  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
769  return;
770  }
771  identity = handle->url + strlen (GNUNET_REST_API_NS_IDENTITY_TICKETS) + 1;
772 
773  for (ego_entry = ego_head; NULL != ego_entry;
774  ego_entry = ego_entry->next)
775  if (0 == strcmp (identity, ego_entry->identifier))
776  break;
777  handle->resp_object = json_array ();
778 
779  if (NULL == ego_entry)
780  {
781  // Done
782  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
784  return;
785  }
786  priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
787  handle->ticket_it =
789  priv_key,
791  handle,
793  handle,
795  handle);
796 }
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:1637
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:595
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:1296
struct GNUNET_RECLAIM_TicketIterator * ticket_it
Ticket iterator.
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
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.
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 struct EgoEntry * ego_head
Ego list.
#define GNUNET_log(kind,...)
static struct GNUNET_RECLAIM_Handle * idp
Identity Provider.
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 800 of file plugin_rest_reclaim.c.

References GNUNET_REST_RequestHandle::data, GNUNET_REST_RequestHandle::data_size, do_error(), EgoEntry::ego, finished_cont(), GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_IDENTITY_ego_get_private_key(), GNUNET_JSON_parse(), GNUNET_JSON_parse_free(), GNUNET_JSON_spec_end(), GNUNET_log, GNUNET_memcpy, GNUNET_OK, GNUNET_RECLAIM_attribute_store(), GNUNET_RECLAIM_id_generate, GNUNET_RECLAIM_id_is_zero, GNUNET_RECLAIM_JSON_spec_attribute(), GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, GNUNET_SCHEDULER_add_now(), GNUNET_TIME_UNIT_HOURS, GNUNET_YES, handle, GNUNET_RECLAIM_Attribute::id, EgoEntry::identifier, identity, RequestHandle::idp_op, EgoEntry::next, RequestHandle::rest_handle, and RequestHandle::url.

Referenced by rest_identity_process_request().

803 {
804  const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv;
805  const char *identity;
806  struct RequestHandle *handle = cls;
807  struct EgoEntry *ego_entry;
808  struct GNUNET_RECLAIM_Attribute *attribute;
809  struct GNUNET_TIME_Relative exp;
810  char term_data[handle->rest_handle->data_size + 1];
811  json_t *data_json;
812  json_error_t err;
813  struct GNUNET_JSON_Specification attrspec[] =
815 
817  "Adding an attribute for %s.\n",
818  handle->url);
819  if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) >= strlen (handle->url))
820  {
821  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
823  return;
824  }
825  identity = handle->url + strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) + 1;
826 
827  for (ego_entry = ego_head; NULL != ego_entry;
828  ego_entry = ego_entry->next)
829  if (0 == strcmp (identity, ego_entry->identifier))
830  break;
831 
832  if (NULL == ego_entry)
833  {
834  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Identity unknown (%s)\n", identity);
835  return;
836  }
837  identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
838 
839  if (0 >= handle->rest_handle->data_size)
840  {
842  return;
843  }
844 
845  term_data[handle->rest_handle->data_size] = '\0';
846  GNUNET_memcpy (term_data,
847  handle->rest_handle->data,
848  handle->rest_handle->data_size);
849  data_json = json_loads (term_data, JSON_DECODE_ANY, &err);
851  GNUNET_JSON_parse (data_json, attrspec, NULL, NULL));
852  json_decref (data_json);
853  if (NULL == attribute)
854  {
856  "Unable to parse attribute from %s\n",
857  term_data);
859  return;
860  }
864  if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&attribute->id))
865  GNUNET_RECLAIM_id_generate (&attribute->id);
868  identity_priv,
869  attribute,
870  &exp,
871  &finished_cont,
872  handle);
873  GNUNET_JSON_parse_free (attrspec);
874 }
#define GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES
Attribute namespace.
#define GNUNET_TIME_UNIT_HOURS
One hour.
size_t data_size
The POST data size.
enum GNUNET_GenericReturnValue GNUNET_JSON_parse(const json_t *root, struct GNUNET_JSON_Specification *spec, const char **error_json_name, unsigned int *error_line)
Navigate and parse data in a JSON tree.
Definition: json.c:45
#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:595
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
Entry in parser specification for GNUNET_JSON_parse().
Private ECC key encoded for transmission.
The request handle.
The ego list.
struct GNUNET_JSON_Specification GNUNET_RECLAIM_JSON_spec_attribute(struct GNUNET_RECLAIM_Attribute **attr)
JSON Specification for Reclaim claims.
Definition: json_reclaim.c:145
struct GNUNET_IDENTITY_Ego * ego
The Ego.
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:1296
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
struct GNUNET_RECLAIM_Identifier id
ID.
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:1135
struct GNUNET_REST_RequestHandle * rest_handle
Rest connection.
const char * data
The POST data.
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 struct EgoEntry * ego_head
Ego list.
#define GNUNET_log(kind,...)
struct GNUNET_RECLAIM_Operation * idp_op
Idp Operation.
static struct GNUNET_RECLAIM_Handle * idp
Identity Provider.
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 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_Credential cred,
const char *  claim 
)

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

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

Definition at line 886 of file plugin_rest_reclaim.c.

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

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

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

Referenced by list_attribute_cont().

954 {
955  struct RequestHandle *handle = cls;
956  json_t *attr_obj;
957  const char *type;
958  char *id_str;
959 
960  char *tmp_value;
962  attr->data,
963  attr->data_size);
964  attr_obj = json_object ();
965  json_object_set_new (attr_obj, "value", json_string (tmp_value));
966  json_object_set_new (attr_obj, "name", json_string (attr->name));
967 
969  json_object_set_new (attr_obj, "flag", json_string ("0"));
970  else
971  json_object_set_new (attr_obj, "flag", json_string ("1"));
973  json_object_set_new (attr_obj, "type", json_string (type));
974  id_str = GNUNET_STRINGS_data_to_string_alloc (&attr->id,
975  sizeof(attr->id));
976  json_object_set_new (attr_obj, "id", json_string (id_str));
978  sizeof(attr->credential));
979  json_object_set_new (attr_obj, "credential", json_string (id_str));
980  json_array_append (handle->resp_object, attr_obj);
981  json_decref (attr_obj);
982  GNUNET_free (tmp_value);
984 }
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:1377
struct GNUNET_RECLAIM_Identifier credential
Referenced ID of credential (may be GNUNET_RECLAIM_ID_ZERO if self-creded)
The request handle.
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:936
#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 995 of file plugin_rest_reclaim.c.

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

Referenced by rest_identity_process_request().

998 {
999  const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key;
1000  struct RequestHandle *handle = cls;
1001  struct EgoEntry *ego_entry;
1002  char *identity;
1003 
1005  "Getting attributes for %s.\n",
1006  handle->url);
1007  if (strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) >= strlen (handle->url))
1008  {
1009  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n");
1011  return;
1012  }
1013  identity = handle->url + strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) + 1;
1014 
1015  for (ego_entry = ego_head; NULL != ego_entry;
1016  ego_entry = ego_entry->next)
1017  if (0 == strcmp (identity, ego_entry->identifier))
1018  break;
1019  handle->resp_object = json_array ();
1020 
1021 
1022  if (NULL == ego_entry)
1023  {
1024  // Done
1025  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ego %s not found.\n", identity);
1027  return;
1028  }
1029  priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
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:1331
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:595
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:1296
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
static void return_response(void *cls)
Return attributes for identity.
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 struct EgoEntry * ego_head
Ego list.
static void attr_collect(void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_Attribute *attr)
Collect all attributes for an ego.
#define GNUNET_log(kind,...)
static struct GNUNET_RECLAIM_Handle * idp
Identity Provider.
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, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_IDENTITY_ego_get_private_key(), GNUNET_log, GNUNET_RECLAIM_attribute_delete(), GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, GNUNET_SCHEDULER_add_now(), GNUNET_STRINGS_string_to_data(), handle, GNUNET_RECLAIM_Attribute::id, id, EgoEntry::identifier, identity, RequestHandle::idp_op, GNUNET_RECLAIM_Attribute::name, EgoEntry::next, RequestHandle::resp_object, return_response(), and RequestHandle::url.

Referenced by rest_identity_process_request().

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 = 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  memset (&attr, 0, sizeof(struct GNUNET_RECLAIM_Attribute));
1095  GNUNET_STRINGS_string_to_data (id, strlen (id), &attr.id, sizeof(attr.id));
1096  attr.name = "";
1098  priv_key,
1099  &attr,
1101  handle);
1102  GNUNET_free (identity_id_str);
1103 }
#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:1182
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:595
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:1296
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
static void return_response(void *cls)
Return attributes for identity.
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.
static struct EgoEntry * ego_head
Ego list.
#define GNUNET_log(kind,...)
struct GNUNET_RECLAIM_Operation * idp_op
Idp Operation.
static struct GNUNET_RECLAIM_Handle * idp
Identity Provider.
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:971
#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 1107 of file plugin_rest_reclaim.c.

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

Referenced by rest_identity_process_request().

1110 {
1111  const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv;
1112  struct RequestHandle *handle = cls;
1113  struct EgoEntry *ego_entry;
1114  struct GNUNET_RECLAIM_Ticket *ticket = NULL;
1115  struct GNUNET_CRYPTO_EcdsaPublicKey tmp_pk;
1116  char term_data[handle->rest_handle->data_size + 1];
1117  json_t *data_json;
1118  json_error_t err;
1119  struct GNUNET_JSON_Specification tktspec[] =
1121 
1122  if (0 >= handle->rest_handle->data_size)
1123  {
1125  return;
1126  }
1127 
1128  term_data[handle->rest_handle->data_size] = '\0';
1129  GNUNET_memcpy (term_data,
1130  handle->rest_handle->data,
1131  handle->rest_handle->data_size);
1132  data_json = json_loads (term_data, JSON_DECODE_ANY, &err);
1133  if ((NULL == data_json) ||
1134  (GNUNET_OK != GNUNET_JSON_parse (data_json, tktspec, NULL, NULL)))
1135  {
1136  handle->emsg = GNUNET_strdup ("Not a ticket!\n");
1138  GNUNET_JSON_parse_free (tktspec);
1139  if (NULL != data_json)
1140  json_decref (data_json);
1141  return;
1142  }
1143  json_decref (data_json);
1144  if (NULL == ticket)
1145  {
1147  "Unable to parse ticket from %s\n",
1148  term_data);
1150  return;
1151  }
1152 
1153  for (ego_entry = ego_head; NULL != ego_entry;
1154  ego_entry = ego_entry->next)
1155  {
1156  GNUNET_IDENTITY_ego_get_public_key (ego_entry->ego, &tmp_pk);
1157  if (0 == memcmp (&ticket->identity,
1158  &tmp_pk,
1159  sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)))
1160  break;
1161  }
1162  if (NULL == ego_entry)
1163  {
1164  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Identity unknown\n");
1165  GNUNET_JSON_parse_free (tktspec);
1166  return;
1167  }
1168  identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
1169 
1171  identity_priv,
1172  ticket,
1173  &finished_cont,
1174  handle);
1175  GNUNET_JSON_parse_free (tktspec);
1176 }
The authorization ticket.
size_t data_size
The POST data size.
enum GNUNET_GenericReturnValue GNUNET_JSON_parse(const json_t *root, struct GNUNET_JSON_Specification *spec, const char **error_json_name, unsigned int *error_line)
Navigate and parse data in a JSON tree.
Definition: json.c:45
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:595
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
Entry in parser specification for GNUNET_JSON_parse().
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:1732
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:1296
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
struct GNUNET_REST_RequestHandle * rest_handle
Rest connection.
const char * data
The POST data.
struct GNUNET_CRYPTO_EcdsaPublicKey identity
The ticket issuer (= the user)
static void do_error(void *cls)
Task run on error, sends error message.
static 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.
static struct GNUNET_RECLAIM_Handle * idp
Identity Provider.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_end(void)
End of a parser specification.
Definition: json_helper.c:35
void GNUNET_IDENTITY_ego_get_public_key(struct GNUNET_IDENTITY_Ego *ego, struct GNUNET_CRYPTO_EcdsaPublicKey *pk)
Get the identifier (public key) of an ego.
Definition: identity_api.c:608
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:266
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_Presentation pres 
)
static

Definition at line 1180 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().

1184 {
1185  struct RequestHandle *handle = cls;
1186  char *val_str;
1187  json_t *value;
1188 
1189  if (NULL == identity)
1190  {
1192  return;
1193  }
1194 
1195  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute: %s\n", attr->name);
1197  attr->data,
1198  attr->data_size);
1199  if (NULL == val_str)
1200  {
1202  "Failed to parse value for: %s\n",
1203  attr->name);
1204  return;
1205  }
1206  value = json_string (val_str);
1207  json_object_set_new (handle->resp_object, attr->name, value);
1208  json_decref (value);
1209  GNUNET_free (val_str);
1210 }
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:1296
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 1214 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::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_JSON_spec_ticket(), GNUNET_RECLAIM_ticket_consume(), GNUNET_SCHEDULER_add_now(), GNUNET_strdup, handle, RequestHandle::idp_op, EgoEntry::next, RequestHandle::resp_object, RequestHandle::rest_handle, and ticket.

Referenced by rest_identity_process_request().

1217 {
1218  const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity_priv;
1219  struct RequestHandle *handle = cls;
1220  struct EgoEntry *ego_entry;
1221  struct GNUNET_RECLAIM_Ticket *ticket;
1222  struct GNUNET_CRYPTO_EcdsaPublicKey tmp_pk;
1223  char term_data[handle->rest_handle->data_size + 1];
1224  json_t *data_json;
1225  json_error_t err;
1226  struct GNUNET_JSON_Specification tktspec[] =
1228 
1229  if (0 >= handle->rest_handle->data_size)
1230  {
1232  return;
1233  }
1234 
1235  term_data[handle->rest_handle->data_size] = '\0';
1236  GNUNET_memcpy (term_data,
1237  handle->rest_handle->data,
1238  handle->rest_handle->data_size);
1239  data_json = json_loads (term_data, JSON_DECODE_ANY, &err);
1240  if (NULL == data_json)
1241  {
1243  "Unable to parse JSON Object from %s\n",
1244  term_data);
1246  return;
1247  }
1248  if (GNUNET_OK != GNUNET_JSON_parse (data_json, tktspec, NULL, NULL))
1249  {
1250  handle->emsg = GNUNET_strdup ("Not a ticket!\n");
1252  GNUNET_JSON_parse_free (tktspec);
1253  json_decref (data_json);
1254  return;
1255  }
1256  for (ego_entry = ego_head; NULL != ego_entry;
1257  ego_entry = ego_entry->next)
1258  {
1259  GNUNET_IDENTITY_ego_get_public_key (ego_entry->ego, &tmp_pk);
1260  if (0 == memcmp (&ticket->audience,
1261  &tmp_pk,
1262  sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)))
1263  break;
1264  }
1265  if (NULL == ego_entry)
1266  {
1267  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Identity unknown\n");
1268  GNUNET_JSON_parse_free (tktspec);
1269  return;
1270  }
1271  identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
1272  handle->resp_object = json_object ();
1274  identity_priv,
1275  ticket,
1276  &consume_cont,
1277  handle);
1278  GNUNET_JSON_parse_free (tktspec);
1279 }
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:1591
size_t data_size
The POST data size.
enum GNUNET_GenericReturnValue GNUNET_JSON_parse(const json_t *root, struct GNUNET_JSON_Specification *spec, const char **error_json_name, unsigned int *error_line)
Navigate and parse data in a JSON tree.
Definition: json.c:45
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:595
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
Entry in parser specification for GNUNET_JSON_parse().
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.
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:1296
static struct GNUNET_DNS_Handle * handle
Handle to transport service.
struct GNUNET_REST_RequestHandle * rest_handle
Rest connection.
const char * data
The POST data.
static void do_error(void *cls)
Task run on error, sends error message.
static struct EgoEntry * ego_head
Ego list.
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,...)
struct GNUNET_RECLAIM_Operation * idp_op
Idp Operation.
static struct GNUNET_RECLAIM_Handle * idp
Identity Provider.
static void consume_cont(void *cls, const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, const struct GNUNET_RECLAIM_Attribute *attr, const struct GNUNET_RECLAIM_Presentation *pres)
struct GNUNET_JSON_Specification GNUNET_JSON_spec_end(void)
End of a parser specification.
Definition: json_helper.c:35
void GNUNET_IDENTITY_ego_get_public_key(struct GNUNET_IDENTITY_Ego *ego, struct GNUNET_CRYPTO_EcdsaPublicKey *pk)
Get the identifier (public key) of an ego.
Definition: identity_api.c:608
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:266
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 1290 of file plugin_rest_reclaim.c.

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

Referenced by rest_identity_process_request().

1293 {
1294  struct MHD_Response *resp;
1295  struct RequestHandle *handle = cls;
1296 
1297  // For now, independent of path return all options
1298  resp = GNUNET_REST_create_response (NULL);
1299  MHD_add_response_header (resp, "Access-Control-Allow-Methods", allow_methods);
1300  handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
1301  cleanup_handle (handle);
1302  return;
1303 }
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 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
static void cleanup_handle(void *cls)
Cleanup lookup handle.
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 1340 of file plugin_rest_reclaim.c.

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

Referenced by libgnunet_plugin_rest_reclaim_init().

1344 {
1345  struct EgoEntry *ego_entry;
1347 
1348  if ((NULL == ego) && (ID_REST_STATE_INIT == state))
1349  {
1351  return;
1352  }
1353  if (ID_REST_STATE_INIT == state)
1354  {
1355  ego_entry = GNUNET_new (struct EgoEntry);
1358  ego_entry->ego = ego;
1359  ego_entry->identifier = GNUNET_strdup (identifier);
1361  ego_tail,
1362  ego_entry);
1363  }
1364  /* Ego renamed or added */
1365  if (identifier != NULL)
1366  {
1367  for (ego_entry = ego_head; NULL != ego_entry;
1368  ego_entry = ego_entry->next)
1369  {
1370  if (ego_entry->ego == ego)
1371  {
1372  /* Rename */
1373  GNUNET_free (ego_entry->identifier);
1374  ego_entry->identifier = GNUNET_strdup (identifier);
1375  break;
1376  }
1377  }
1378  if (NULL == ego_entry)
1379  {
1380  /* Add */
1381  ego_entry = GNUNET_new (struct EgoEntry);
1384  ego_entry->ego = ego;
1385  ego_entry->identifier = GNUNET_strdup (identifier);
1387  ego_tail,
1388  ego_entry);
1389  }
1390  }
1391  else
1392  {
1393  /* Delete */
1394  for (ego_entry = ego_head; NULL != ego_entry;
1395  ego_entry = ego_entry->next)
1396  {
1397  if (ego_entry->ego == ego)
1398  break;
1399  }
1400  if (NULL == ego_entry)
1401  return; /* Not found */
1402 
1404  ego_tail,
1405  ego_entry);
1406  GNUNET_free (ego_entry->identifier);
1407  GNUNET_free (ego_entry->keystring);
1408  GNUNET_free (ego_entry);
1409  return;
1410  }
1411 
1412 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
static struct EgoEntry * ego_tail
Ego list.
struct GNUNET_CRYPTO_EcdsaPrivateKey pk
Private key from command line option, or NULL.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
The ego list.
struct GNUNET_IDENTITY_Ego * ego
The Ego.
#define ID_REST_STATE_INIT
State while collecting all egos.
#define ID_REST_STATE_POST_INIT
Done collecting egos.
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:232
char * keystring
Public key string.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
char * identifier
Ego Identifier.
static struct EgoEntry * ego_head
Ego list.
Public ECC key (always for Curve25519) encoded in a format suitable for network transmission and ECDS...
static int state
The processing state.
void GNUNET_IDENTITY_ego_get_public_key(struct GNUNET_IDENTITY_Ego *ego, struct GNUNET_CRYPTO_EcdsaPublicKey *pk)
Get the identifier (public key) of an ego.
Definition: identity_api.c:608
struct EgoEntry * next
DLL.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rest_identity_process_request()

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

Definition at line 1416 of file plugin_rest_reclaim.c.

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

Referenced by libgnunet_plugin_rest_reclaim_init().

1419 {
1420  struct RequestHandle *handle = GNUNET_new (struct RequestHandle);
1422  static const struct GNUNET_REST_RequestHandler handlers[] =
1423  { { MHD_HTTP_METHOD_GET,
1425  { MHD_HTTP_METHOD_POST,
1427  { MHD_HTTP_METHOD_DELETE,
1429  { MHD_HTTP_METHOD_GET,
1431  { MHD_HTTP_METHOD_POST,
1433  { MHD_HTTP_METHOD_DELETE,
1435  { MHD_HTTP_METHOD_GET,
1437  { MHD_HTTP_METHOD_POST,
1439  { MHD_HTTP_METHOD_POST,
1441  { MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_RECLAIM, &options_cont },
1443  };
1444 
1445  handle->response_code = 0;
1447  handle->proc_cls = proc_cls;
1448  handle->proc = proc;
1449  handle->rest_handle = rest_handle;
1450 
1451  handle->url = GNUNET_strdup (rest_handle->url);
1452  if (handle->url[strlen (handle->url) - 1] == '/')
1453  handle->url[strlen (handle->url) - 1] = '\0';
1454  handle->timeout_task =
1455  GNUNET_SCHEDULER_add_delayed (handle->timeout, &do_timeout, handle);
1457  requests_tail,
1458  handle);
1459  if (GNUNET_NO ==
1460  GNUNET_REST_handle_request (handle->rest_handle, handlers, &err, handle))
1461  {
1462  cleanup_handle (handle);
1463  return GNUNET_NO;
1464  }
1465 
1466  return GNUNET_YES;
1467 }
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)
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
static void add_attribute_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
GNUNET_REST_ResultProcessor proc
The plugin result processor.
#define GNUNET_REST_API_NS_RECLAIM_CREDENTIAL
Credential namespace.
#define GNUNET_REST_API_NS_IDENTITY_CONSUME
Revoke namespace.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
void(* proc)(struct GNUNET_REST_RequestHandle *handle, const char *url, void *cls)
Namespace to handle.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
void * proc_cls
The closure of the result processor.
static void options_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
Respond to OPTIONS request.
#define GNUNET_REST_HANDLER_END
The request handle.
static void delete_credential_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
Deletes credential from an identity.
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:1269
static struct GNUNET_CADET_MessageHandler handlers[]
Handlers, for diverse services.
const char * url
The url as string.
static struct RequestHandle * requests_tail
DLL.
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".
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 revoke_ticket_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
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.
static struct RequestHandle * requests_head
DLL.
static void cleanup_handle(void *cls)
Cleanup lookup handle.
static void list_credential_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
Lists credential for identity request.
static void add_credential_cont(struct GNUNET_REST_RequestHandle *con_handle, const char *url, void *cls)
#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:

◆ 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 1477 of file plugin_rest_reclaim.c.

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

1478 {
1479  static struct Plugin plugin;
1480  struct GNUNET_REST_Plugin *api;
1481 
1482  cfg = cls;
1483  if (NULL != plugin.cfg)
1484  return NULL; /* can only initialize once! */
1485  memset (&plugin, 0, sizeof(struct Plugin));
1486  plugin.cfg = cfg;
1487  api = GNUNET_new (struct GNUNET_REST_Plugin);
1488  api->cls = &plugin;
1492  "%s, %s, %s, %s, %s",
1493  MHD_HTTP_METHOD_GET,
1494  MHD_HTTP_METHOD_POST,
1495  MHD_HTTP_METHOD_PUT,
1496  MHD_HTTP_METHOD_DELETE,
1497  MHD_HTTP_METHOD_OPTIONS);
1502  _ ("Identity Provider REST API initialized\n"));
1503  return api;
1504 }
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:566
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.
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.
#define _(String)
GNU gettext support macro.
Definition: platform.h:184
#define ID_REST_STATE_INIT
State while collecting all egos.
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.
static struct GNUNET_IDENTITY_Handle * identity_handle
Handle to Identity service.
Handle for a plugin.
Definition: block.c:37
#define GNUNET_log(kind,...)
static struct GNUNET_RECLAIM_Handle * idp
Identity Provider.
static int state
The processing state.
enum GNUNET_GenericReturnValue(* process_request)(struct GNUNET_REST_RequestHandle *handle, GNUNET_REST_ResultProcessor proc, void *proc_cls)
Function to process a REST call.
struct GNUNET_RECLAIM_Handle * GNUNET_RECLAIM_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the re:claimID service.
Definition: reclaim_api.c:1064
static enum GNUNET_GenericReturnValue rest_identity_process_request(struct GNUNET_REST_RequestHandle *rest_handle, GNUNET_REST_ResultProcessor proc, void *proc_cls)
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 1514 of file plugin_rest_reclaim.c.

References allow_methods, Plugin::api, Plugin::cfg, GNUNET_REST_Plugin::cls, do_error(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_IDENTITY_disconnect(), GNUNET_log, GNUNET_RECLAIM_disconnect(), EgoEntry::identifier, EgoEntry::keystring, EgoEntry::next, plugin, and request.

1515 {
1516  struct GNUNET_REST_Plugin *api = cls;
1517  struct Plugin *plugin = api->cls;
1518  struct RequestHandle *request;
1519  struct EgoEntry *ego_entry;
1520  struct EgoEntry *ego_tmp;
1521 
1522  plugin->cfg = NULL;
1523  while (NULL != (request = requests_head))
1524  do_error (request);
1525  if (NULL != idp)
1527  if (NULL != identity_handle)
1529  for (ego_entry = ego_head; NULL != ego_entry;)
1530  {
1531  ego_tmp = ego_entry;
1532  ego_entry = ego_entry->next;
1533  GNUNET_free (ego_tmp->identifier);
1534  GNUNET_free (ego_tmp->keystring);
1535  GNUNET_free (ego_tmp);
1536  }
1537 
1539  GNUNET_free (api);
1541  "Identity Provider REST plugin is finished\n");
1542  return NULL;
1543 }
static struct GNUNET_VPN_RedirectionRequest * request
Opaque redirection request handle.
Definition: gnunet-vpn.c:41
void * cls
The closure of the plugin.
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
void GNUNET_RECLAIM_disconnect(struct GNUNET_RECLAIM_Handle *h)
Disconnect from identity provider service.
Definition: reclaim_api.c:1104
struct returned by the initialization function of the plugin
The request handle.
The ego list.
static char * allow_methods
HTTP methods allows for this plugin.
void GNUNET_IDENTITY_disconnect(struct GNUNET_IDENTITY_Handle *h)
Disconnect from identity service.
Definition: identity_api.c:884
static char * plugin
Solver plugin name as string.
char * keystring
Public key string.
static void do_error(void *cls)
Task run on error, sends error message.
char * identifier
Ego Identifier.
static struct EgoEntry * ego_head
Ego list.
static struct GNUNET_IDENTITY_Handle * identity_handle
Handle to Identity service.
Handle for a plugin.
Definition: block.c:37
static struct RequestHandle * requests_head
DLL.
#define GNUNET_log(kind,...)
static struct GNUNET_RECLAIM_Handle * idp
Identity Provider.
struct EgoEntry * next
DLL.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:

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

◆ ego_head

struct EgoEntry* ego_head
static

Ego list.

Definition at line 93 of file plugin_rest_reclaim.c.

◆ ego_tail

struct EgoEntry* ego_tail
static

Ego list.

Definition at line 98 of file plugin_rest_reclaim.c.

◆ state

int state
static

The processing state.

Definition at line 103 of file plugin_rest_reclaim.c.

Referenced by libgnunet_plugin_rest_reclaim_init(), and list_ego().

◆ identity_handle

struct GNUNET_IDENTITY_Handle* identity_handle
static

Handle to Identity service.

Definition at line 108 of file plugin_rest_reclaim.c.

◆ idp

struct GNUNET_RECLAIM_Handle* idp
static

Identity Provider.

Definition at line 113 of file plugin_rest_reclaim.c.

◆ requests_head

struct RequestHandle* requests_head
static

DLL.

Definition at line 261 of file plugin_rest_reclaim.c.

◆ requests_tail

struct RequestHandle* requests_tail
static

DLL.

Definition at line 266 of file plugin_rest_reclaim.c.