summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2021-04-21 12:26:34 +0200
committerMartin Schanzenbach <mschanzenbach@posteo.de>2021-04-21 12:26:34 +0200
commit6c1b06b0629b146981fcdfb5ecea40bbc6450a9e (patch)
treee8131f10c208a44eefd7a84a3e6e9c77879ffa2d /src
parent316a9ea66e029fc0ced2c76de42ba044d377ccec (diff)
-fix expiration
Diffstat (limited to 'src')
-rw-r--r--src/reclaim/plugin_reclaim_credential_pabc.c51
-rw-r--r--src/reclaim/plugin_rest_pabc.c19
2 files changed, 35 insertions, 35 deletions
diff --git a/src/reclaim/plugin_reclaim_credential_pabc.c b/src/reclaim/plugin_reclaim_credential_pabc.c
index c993ba485..ff04624a4 100644
--- a/src/reclaim/plugin_reclaim_credential_pabc.c
+++ b/src/reclaim/plugin_reclaim_credential_pabc.c
@@ -146,8 +146,8 @@ pabc_number_to_typename (void *cls, uint32_t type)
static void
inspect_attrs (char const *const key,
- char const *const value,
- void *ctx)
+ char const *const value,
+ void *ctx)
{
struct GNUNET_RECLAIM_AttributeList *attrs = ctx;
@@ -228,6 +228,7 @@ pabc_parse_attributes_p (void *cls,
return pabc_parse_attributes (cls, cred->data, cred->data_size);
}
+
/**
* Parse a pabc and return the issuer
*
@@ -296,43 +297,27 @@ pabc_get_expiration (void *cls,
size_t data_size,
struct GNUNET_TIME_Absolute *exp)
{
- json_t *json_root;
- json_t *json_attrs;
- json_t *value;
- json_t *exp_j;
- json_error_t *json_err = NULL;
-
- json_root = json_loads (data, JSON_DECODE_ANY, json_err);
- if ((NULL == json_root) ||
- (! json_is_object (json_root)))
+ uint32_t exp_i;
+ char *exp_str;
+
+ if (PABC_OK != pabc_cred_get_attr_by_name_from_cred (data,
+ "expiration",
+ &exp_str))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%s is not a valid pabc credentials (not an object)\n",
- data);
- if (NULL != json_root)
- json_decref (json_root);
+ "Unable to retrive expiration from credential\n");
return GNUNET_SYSERR;
}
- json_attrs = json_object_get (json_root, PABC_JSON_PLAIN_ATTRS_KEY);
- if ((NULL == json_attrs) ||
- (! json_is_object (json_attrs)))
+
+ if (1 != sscanf (exp_str, "%u", &exp_i))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%s is not a valid pabc credential (attributes not an object)\n",
- data);
- json_decref (json_root);
+ "Invalid expiration `%s'\n", exp_str);
+ GNUNET_free (exp_str);
return GNUNET_SYSERR;
}
- exp_j = json_object_get (json_attrs, "expiration");
- if ((NULL != exp_j) &&
- json_is_integer (exp_j))
- {
- exp->abs_value_us = json_integer_value (value) * 1000 * 1000;
- json_decref (json_root);
- return GNUNET_OK;
- }
- json_decref (json_root);
- return GNUNET_SYSERR;
+ exp->abs_value_us = exp_i * 1000 * 1000;
+ return GNUNET_OK;
}
@@ -418,8 +403,8 @@ pabc_create_presentation (void *cls,
return GNUNET_SYSERR;
}
if (PABC_OK != pabc_cred_get_attr_by_name_from_cred (credential->data,
- "subject",
- &subject))
+ "subject",
+ &subject))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed to get subject.\n");
diff --git a/src/reclaim/plugin_rest_pabc.c b/src/reclaim/plugin_rest_pabc.c
index 9c1ac3c47..6603fb888 100644
--- a/src/reclaim/plugin_rest_pabc.c
+++ b/src/reclaim/plugin_rest_pabc.c
@@ -259,9 +259,23 @@ set_attributes_from_idtoken (const struct pabc_context *ctx,
continue;
if (0 == strcmp ("aud", key))
continue;
+ char *tmp_val;
+ if (json_is_string (value))
+ tmp_val = GNUNET_strdup (json_string_value (value));
+ else
+ tmp_val = json_dumps (value, JSON_ENCODE_ANY);
+ if (NULL == tmp_val)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Unable to encode JSON value for `%s'\n", key);
+ continue;
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Setting `%s' to `%s'\n", key, tmp_val);
status = pabc_set_attribute_value_by_name (ctx, pp, usr_ctx,
pabc_key,
- json_string_value (value));
+ tmp_val);
+ GNUNET_free (tmp_val);
if (PABC_OK != status)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -501,7 +515,8 @@ cr_cont (struct GNUNET_REST_RequestHandle *con_handle,
}
handle->resp_object = json_object ();
GNUNET_assert (PABC_OK == pabc_cred_encode_cr (ctx, pp, cr,
- json_string_value (identity_json),
+ json_string_value (
+ identity_json),
ppid, &response_str));
if (PABC_OK != status)
{