102 { NULL, UINT32_MAX } };
158 const char *jwt_body;
161 char *val_str = NULL;
165 json_error_t json_err;
170 jwt_body = strtok (jwt_string, delim);
171 if (NULL == jwt_body)
174 "Failed to parse JSON %s\n", jwt_string);
177 jwt_body = strtok (NULL, delim);
178 if (NULL == jwt_body)
181 "Failed to parse JSON %s\n", jwt_string);
186 (
void **) &decoded_jwt);
189 json_val = json_loads (decoded_jwt, JSON_DECODE_ANY, &json_err);
193 const char *addr_key;
197 json_object_foreach (json_val,
key,
value) {
198 if (0 == strcmp (
"iss",
key))
200 if (0 == strcmp (
"jti",
key))
202 if (0 == strcmp (
"exp",
key))
204 if (0 == strcmp (
"iat",
key))
206 if (0 == strcmp (
"nbf",
key))
208 if (0 == strcmp (
"aud",
key))
210 if (0 == strcmp (
"address",
key))
212 if (! json_is_object (
value))
215 "address claim in wrong format!");
218 json_object_foreach (
value, addr_key, addr_value) {
219 val_str = json_dumps (addr_value, JSON_ENCODE_ANY);
225 if (tmp[strlen (tmp) - 1] ==
'"')
226 tmp[strlen (tmp) - 1] =
'\0';
237 val_str = json_dumps (
value, JSON_ENCODE_ANY);
243 if (tmp[strlen (tmp) - 1] ==
'"')
244 tmp[strlen (tmp) - 1] =
'\0';
254 json_decref (json_val);
306 const char *jwt_body;
313 json_error_t json_err;
317 jwt_body = strtok (jwt_string, delim);
318 jwt_body = strtok (NULL, delim);
320 (
void **) &decoded_jwt);
321 json_val = json_loads (decoded_jwt, JSON_DECODE_ANY, &json_err);
324 if (NULL == json_val)
326 issuer_json = json_object_get (json_val,
"iss");
327 if ((NULL == issuer_json) || (! json_is_string (issuer_json)))
329 json_decref (json_val);
333 json_decref (json_val);
385 const char *jwt_body;
391 json_error_t json_err;
395 jwt_body = strtok (jwt_string, delim);
396 jwt_body = strtok (NULL, delim);
398 (
void **) &decoded_jwt);
399 json_val = json_loads (decoded_jwt, JSON_DECODE_ANY, &json_err);
402 if (NULL == json_val)
404 exp_json = json_object_get (json_val,
"exp");
405 if ((NULL == exp_json) || (! json_is_integer (exp_json)))
407 json_decref (json_val);
410 exp->
abs_value_us = json_integer_value (exp_json) * 1000 * 1000;
411 json_decref (json_val);
static gnutls_certificate_credentials_t cred
The credential.
static char * data
The data to insert into the dht.
struct GNUNET_HashCode key
The key used in the DHT.
static char * value
Value of the record to add/remove.
static uint32_t type
Type string converted to DNS type value.
static size_t data_size
Number of bytes in data.
Plugin API for reclaim attribute types.
#define GNUNET_log(kind,...)
GNUNET_GenericReturnValue
Named constants for return values.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_strndup(a, length)
Wrapper around GNUNET_xstrndup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_RECLAIM_Presentation * GNUNET_RECLAIM_presentation_new(uint32_t type, const void *data, size_t data_size)
void GNUNET_RECLAIM_attribute_list_add(struct GNUNET_RECLAIM_AttributeList *attrs, const char *attr_name, const struct GNUNET_RECLAIM_Identifier *credential, uint32_t type, const void *data, size_t data_size)
Add a new attribute to a claim list.
@ GNUNET_RECLAIM_CREDENTIAL_TYPE_JWT
A JSON Web Token credential.
@ GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING
String attribute.
size_t GNUNET_STRINGS_base64url_decode(const char *data, size_t len, void **out)
Decode from Base64url.
static enum GNUNET_GenericReturnValue jwt_create_presentation(void *cls, const struct GNUNET_RECLAIM_Credential *cred, const struct GNUNET_RECLAIM_AttributeList *attrs, struct GNUNET_RECLAIM_Presentation **presentation)
static struct GNUNET_RECLAIM_AttributeList * jwt_parse_attributes(void *cls, const char *data, size_t data_size)
Parse a JWT and return the respective claim value as Attribute.
static char * jwt_get_issuer_c(void *cls, const struct GNUNET_RECLAIM_Credential *cred)
Parse a JWT and return the issuer.
void * libgnunet_plugin_reclaim_credential_jwt_done(void *cls)
Exit point from the plugin.
static char * jwt_get_issuer(void *cls, const char *data, size_t data_size)
Parse a JWT and return the issuer.
static struct GNUNET_RECLAIM_AttributeList * jwt_parse_attributes_c(void *cls, const struct GNUNET_RECLAIM_Credential *cred)
Parse a JWT and return the respective claim value as Attribute.
static enum GNUNET_GenericReturnValue jwt_get_expiration(void *cls, const char *data, size_t data_size, struct GNUNET_TIME_Absolute *exp)
Parse a JWT and return the expiration.
static char * jwt_get_issuer_p(void *cls, const struct GNUNET_RECLAIM_Presentation *cred)
Parse a JWT and return the issuer.
static char * jwt_value_to_string(void *cls, uint32_t type, const void *data, size_t data_size)
Convert the 'value' of an credential to a string.
static uint32_t jwt_typename_to_number(void *cls, const char *jwt_typename)
Convert a type name to the corresponding number.
void * libgnunet_plugin_reclaim_credential_jwt_init(void *cls)
Entry point for the plugin.
static const char * jwt_number_to_typename(void *cls, uint32_t type)
Convert a type number to the corresponding type string (e.g.
static int jwt_string_to_value(void *cls, uint32_t type, const char *s, void **data, size_t *data_size)
Convert human-readable version of a 'value' of an credential to the binary representation.
static enum GNUNET_GenericReturnValue jwt_get_expiration_p(void *cls, const struct GNUNET_RECLAIM_Presentation *cred, struct GNUNET_TIME_Absolute *exp)
Parse a JWT and return the expiration.
static struct @42 jwt_cred_name_map[]
Mapping of credential type numbers to human-readable credential type names.
static struct GNUNET_RECLAIM_AttributeList * jwt_parse_attributes_p(void *cls, const struct GNUNET_RECLAIM_Presentation *cred)
Parse a JWT and return the respective claim value as Attribute.
static enum GNUNET_GenericReturnValue jwt_get_expiration_c(void *cls, const struct GNUNET_RECLAIM_Credential *cred, struct GNUNET_TIME_Absolute *exp)
Parse a JWT and return the expiration.
A list of GNUNET_RECLAIM_Attribute structures.
Each plugin is required to return a pointer to a struct of this type as the return value from its ent...
GNUNET_RECLAIM_CredentialValueToStringFunction value_to_string
Conversion to string.
GNUNET_RECLAIM_CredentialTypenameToNumberFunction typename_to_number
Typename to number.
GNUNET_RECLAIM_PresentationGetIssuerFunction get_issuer_p
Attesation issuer.
GNUNET_RECLAIM_CredentialNumberToTypenameFunction number_to_typename
Number to typename.
GNUNET_RECLAIM_CredentialGetIssuerFunction get_issuer
Attesation issuer.
GNUNET_RECLAIM_PresentationGetExpirationFunction get_expiration_p
Expiration.
GNUNET_RECLAIM_PresentationValueToStringFunction value_to_string_p
Conversion to string.
GNUNET_RECLAIM_CredentialStringToValueFunction string_to_value
Conversion to binary.
GNUNET_RECLAIM_CredentialGetExpirationFunction get_expiration
Expiration.
void * cls
Closure for all of the callbacks.
GNUNET_RECLAIM_CredentialGetAttributesFunction get_attributes
Attesation attributes.
GNUNET_RECLAIM_PresentationStringToValueFunction string_to_value_p
Conversion to binary.
GNUNET_RECLAIM_PresentationTypenameToNumberFunction typename_to_number_p
Typename to number.
GNUNET_RECLAIM_PresentationNumberToTypenameFunction number_to_typename_p
Number to typename.
GNUNET_RECLAIM_CredentialToPresentation create_presentation
Get presentation.
GNUNET_RECLAIM_PresentationGetAttributesFunction get_attributes_p
Attesation attributes.
A credential presentation.
Time for absolute times used by GNUnet, in microseconds.
uint64_t abs_value_us
The actual value.