aboutsummaryrefslogtreecommitdiff
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)
downloadgnunet-6c1b06b0629b146981fcdfb5ecea40bbc6450a9e.tar.gz
gnunet-6c1b06b0629b146981fcdfb5ecea40bbc6450a9e.zip
-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)
146 146
147static void 147static void
148inspect_attrs (char const *const key, 148inspect_attrs (char const *const key,
149 char const *const value, 149 char const *const value,
150 void *ctx) 150 void *ctx)
151{ 151{
152 struct GNUNET_RECLAIM_AttributeList *attrs = ctx; 152 struct GNUNET_RECLAIM_AttributeList *attrs = ctx;
153 153
@@ -228,6 +228,7 @@ pabc_parse_attributes_p (void *cls,
228 return pabc_parse_attributes (cls, cred->data, cred->data_size); 228 return pabc_parse_attributes (cls, cred->data, cred->data_size);
229} 229}
230 230
231
231/** 232/**
232 * Parse a pabc and return the issuer 233 * Parse a pabc and return the issuer
233 * 234 *
@@ -296,43 +297,27 @@ pabc_get_expiration (void *cls,
296 size_t data_size, 297 size_t data_size,
297 struct GNUNET_TIME_Absolute *exp) 298 struct GNUNET_TIME_Absolute *exp)
298{ 299{
299 json_t *json_root; 300 uint32_t exp_i;
300 json_t *json_attrs; 301 char *exp_str;
301 json_t *value; 302
302 json_t *exp_j; 303 if (PABC_OK != pabc_cred_get_attr_by_name_from_cred (data,
303 json_error_t *json_err = NULL; 304 "expiration",
304 305 &exp_str))
305 json_root = json_loads (data, JSON_DECODE_ANY, json_err);
306 if ((NULL == json_root) ||
307 (! json_is_object (json_root)))
308 { 306 {
309 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 307 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
310 "%s is not a valid pabc credentials (not an object)\n", 308 "Unable to retrive expiration from credential\n");
311 data);
312 if (NULL != json_root)
313 json_decref (json_root);
314 return GNUNET_SYSERR; 309 return GNUNET_SYSERR;
315 } 310 }
316 json_attrs = json_object_get (json_root, PABC_JSON_PLAIN_ATTRS_KEY); 311
317 if ((NULL == json_attrs) || 312 if (1 != sscanf (exp_str, "%u", &exp_i))
318 (! json_is_object (json_attrs)))
319 { 313 {
320 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 314 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
321 "%s is not a valid pabc credential (attributes not an object)\n", 315 "Invalid expiration `%s'\n", exp_str);
322 data); 316 GNUNET_free (exp_str);
323 json_decref (json_root);
324 return GNUNET_SYSERR; 317 return GNUNET_SYSERR;
325 } 318 }
326 exp_j = json_object_get (json_attrs, "expiration"); 319 exp->abs_value_us = exp_i * 1000 * 1000;
327 if ((NULL != exp_j) && 320 return GNUNET_OK;
328 json_is_integer (exp_j))
329 {
330 exp->abs_value_us = json_integer_value (value) * 1000 * 1000;
331 json_decref (json_root);
332 return GNUNET_OK;
333 }
334 json_decref (json_root);
335 return GNUNET_SYSERR;
336} 321}
337 322
338 323
@@ -418,8 +403,8 @@ pabc_create_presentation (void *cls,
418 return GNUNET_SYSERR; 403 return GNUNET_SYSERR;
419 } 404 }
420 if (PABC_OK != pabc_cred_get_attr_by_name_from_cred (credential->data, 405 if (PABC_OK != pabc_cred_get_attr_by_name_from_cred (credential->data,
421 "subject", 406 "subject",
422 &subject)) 407 &subject))
423 { 408 {
424 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 409 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
425 "Failed to get subject.\n"); 410 "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,
259 continue; 259 continue;
260 if (0 == strcmp ("aud", key)) 260 if (0 == strcmp ("aud", key))
261 continue; 261 continue;
262 char *tmp_val;
263 if (json_is_string (value))
264 tmp_val = GNUNET_strdup (json_string_value (value));
265 else
266 tmp_val = json_dumps (value, JSON_ENCODE_ANY);
267 if (NULL == tmp_val)
268 {
269 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
270 "Unable to encode JSON value for `%s'\n", key);
271 continue;
272 }
273 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
274 "Setting `%s' to `%s'\n", key, tmp_val);
262 status = pabc_set_attribute_value_by_name (ctx, pp, usr_ctx, 275 status = pabc_set_attribute_value_by_name (ctx, pp, usr_ctx,
263 pabc_key, 276 pabc_key,
264 json_string_value (value)); 277 tmp_val);
278 GNUNET_free (tmp_val);
265 if (PABC_OK != status) 279 if (PABC_OK != status)
266 { 280 {
267 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 281 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -501,7 +515,8 @@ cr_cont (struct GNUNET_REST_RequestHandle *con_handle,
501 } 515 }
502 handle->resp_object = json_object (); 516 handle->resp_object = json_object ();
503 GNUNET_assert (PABC_OK == pabc_cred_encode_cr (ctx, pp, cr, 517 GNUNET_assert (PABC_OK == pabc_cred_encode_cr (ctx, pp, cr,
504 json_string_value (identity_json), 518 json_string_value (
519 identity_json),
505 ppid, &response_str)); 520 ppid, &response_str));
506 if (PABC_OK != status) 521 if (PABC_OK != status)
507 { 522 {