diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2015-11-19 15:41:32 +0000 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2015-11-19 15:41:32 +0000 |
commit | 1b41668499df4ced87b98c7b0727381456d39625 (patch) | |
tree | 453e71fa2233fd1286d7805951851ec399e229c8 /src | |
parent | efa9efe25cb84be8cd0f3fb3d545ee6ef7298891 (diff) | |
download | gnunet-1b41668499df4ced87b98c7b0727381456d39625.tar.gz gnunet-1b41668499df4ced87b98c7b0727381456d39625.zip |
- fixes
Diffstat (limited to 'src')
-rw-r--r-- | src/identity-token/gnunet-service-identity-token.c | 8 | ||||
-rw-r--r-- | src/identity-token/plugin_rest_identity_token.c | 52 |
2 files changed, 18 insertions, 42 deletions
diff --git a/src/identity-token/gnunet-service-identity-token.c b/src/identity-token/gnunet-service-identity-token.c index 62999f2f4..5e9376627 100644 --- a/src/identity-token/gnunet-service-identity-token.c +++ b/src/identity-token/gnunet-service-identity-token.c | |||
@@ -188,13 +188,13 @@ handle_token_update (void *cls, | |||
188 | json_object_set_new (new_payload_json, key, json_integer (new_iat.abs_value_us)); | 188 | json_object_set_new (new_payload_json, key, json_integer (new_iat.abs_value_us)); |
189 | } | 189 | } |
190 | else { | 190 | else { |
191 | json_object_set_new (new_payload_json, key, value); | 191 | json_object_set (new_payload_json, key, value); |
192 | } | 192 | } |
193 | } | 193 | } |
194 | json_decref (payload_json); | ||
195 | 194 | ||
196 | // reassemble and set | 195 | // reassemble and set |
197 | new_payload_str = json_dumps (new_payload_json, JSON_COMPACT); | 196 | new_payload_str = json_dumps (new_payload_json, JSON_COMPACT); |
197 | json_decref (payload_json); | ||
198 | json_decref (new_payload_json); | 198 | json_decref (new_payload_json); |
199 | GNUNET_STRINGS_base64_encode (new_payload_str, | 199 | GNUNET_STRINGS_base64_encode (new_payload_str, |
200 | strlen (new_payload_str), | 200 | strlen (new_payload_str), |
@@ -271,7 +271,9 @@ token_collect (void *cls, | |||
271 | //TODO autopurge expired tokens here if set in config | 271 | //TODO autopurge expired tokens here if set in config |
272 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, ">>> Found record\n"); | 272 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, ">>> Found record\n"); |
273 | //There should be only a single record for a token under a label | 273 | //There should be only a single record for a token under a label |
274 | if (1 != rd_count || (rd->record_type != GNUNET_GNSRECORD_TYPE_ID_TOKEN)) | 274 | if ((1 != rd_count) |
275 | || (rd->record_type != GNUNET_GNSRECORD_TYPE_ID_TOKEN) | ||
276 | || (0 == (GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION & rd->flags))) | ||
275 | { | 277 | { |
276 | GNUNET_NAMESTORE_zone_iterator_next (ns_it); | 278 | GNUNET_NAMESTORE_zone_iterator_next (ns_it); |
277 | return; | 279 | return; |
diff --git a/src/identity-token/plugin_rest_identity_token.c b/src/identity-token/plugin_rest_identity_token.c index 316d30c54..e37ab9e52 100644 --- a/src/identity-token/plugin_rest_identity_token.c +++ b/src/identity-token/plugin_rest_identity_token.c | |||
@@ -420,8 +420,6 @@ sign_and_return_token (void *cls, | |||
420 | struct GNUNET_GNSRECORD_Data token_record; | 420 | struct GNUNET_GNSRECORD_Data token_record; |
421 | struct GNUNET_HashCode key; | 421 | struct GNUNET_HashCode key; |
422 | struct GNUNET_TIME_Relative etime_rel; | 422 | struct GNUNET_TIME_Relative etime_rel; |
423 | static struct GNUNET_TIME_Absolute etime_abs; | ||
424 | int etime_is_rel = GNUNET_SYSERR; | ||
425 | int renew_token = GNUNET_NO; | 423 | int renew_token = GNUNET_NO; |
426 | 424 | ||
427 | time = GNUNET_TIME_absolute_get().abs_value_us; | 425 | time = GNUNET_TIME_absolute_get().abs_value_us; |
@@ -447,53 +445,29 @@ sign_and_return_token (void *cls, | |||
447 | return; | 445 | return; |
448 | } | 446 | } |
449 | 447 | ||
450 | if (0 == strcmp (exp_str, "never")) | 448 | if (GNUNET_OK != |
451 | { | ||
452 | etime_abs = GNUNET_TIME_UNIT_FOREVER_ABS; | ||
453 | etime_is_rel = GNUNET_NO; | ||
454 | } | ||
455 | else if (GNUNET_OK == | ||
456 | GNUNET_STRINGS_fancy_time_to_relative (exp_str, | 449 | GNUNET_STRINGS_fancy_time_to_relative (exp_str, |
457 | &etime_rel)) | 450 | &etime_rel)) |
458 | { | 451 | { |
459 | etime_is_rel = GNUNET_YES; | ||
460 | } | ||
461 | else if (GNUNET_OK == | ||
462 | GNUNET_STRINGS_fancy_time_to_absolute (exp_str, | ||
463 | &etime_abs)) | ||
464 | { | ||
465 | etime_is_rel = GNUNET_NO; | ||
466 | } | ||
467 | else { | ||
468 | handle->emsg = GNUNET_strdup ("Expiration invalid!\n"); | 452 | handle->emsg = GNUNET_strdup ("Expiration invalid!\n"); |
469 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 453 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
470 | return; | 454 | return; |
471 | } | 455 | } |
472 | if (GNUNET_YES == etime_is_rel) | 456 | exp_time = time + etime_rel.rel_value_us; |
473 | { | ||
474 | exp_time = time + etime_rel.rel_value_us; | ||
475 | } | ||
476 | else | ||
477 | { | ||
478 | exp_time = etime_abs.abs_value_us; | ||
479 | } | ||
480 | 457 | ||
481 | //Get renewal policy for token | 458 | //Get renewal policy for token |
482 | if (GNUNET_YES == etime_is_rel) | 459 | GNUNET_CRYPTO_hash (GNUNET_IDENTITY_TOKEN_RENEW_TOKEN, |
483 | { | 460 | strlen (GNUNET_IDENTITY_TOKEN_RENEW_TOKEN), |
484 | GNUNET_CRYPTO_hash (GNUNET_IDENTITY_TOKEN_RENEW_TOKEN, | 461 | &key); |
485 | strlen (GNUNET_IDENTITY_TOKEN_RENEW_TOKEN), | ||
486 | &key); | ||
487 | 462 | ||
488 | 463 | ||
489 | if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains (handle->conndata_handle->url_param_map, | 464 | if (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains (handle->conndata_handle->url_param_map, |
490 | &key)) | 465 | &key)) |
491 | { | 466 | { |
492 | renew_str = GNUNET_CONTAINER_multihashmap_get (handle->conndata_handle->url_param_map, | 467 | renew_str = GNUNET_CONTAINER_multihashmap_get (handle->conndata_handle->url_param_map, |
493 | &key); | 468 | &key); |
494 | if (0 == strcmp (renew_str, "true")) | 469 | if (0 == strcmp (renew_str, "true")) |
495 | renew_token = GNUNET_YES; | 470 | renew_token = GNUNET_YES; |
496 | } | ||
497 | } | 471 | } |
498 | 472 | ||
499 | //json_object_set_new (handle->payload, "lbl", json_string (lbl_str)); | 473 | //json_object_set_new (handle->payload, "lbl", json_string (lbl_str)); |
@@ -571,7 +545,7 @@ sign_and_return_token (void *cls, | |||
571 | token_record.expiration_time = exp_time; | 545 | token_record.expiration_time = exp_time; |
572 | token_record.record_type = GNUNET_GNSRECORD_TYPE_ID_TOKEN; | 546 | token_record.record_type = GNUNET_GNSRECORD_TYPE_ID_TOKEN; |
573 | token_record.flags = GNUNET_GNSRECORD_RF_NONE; | 547 | token_record.flags = GNUNET_GNSRECORD_RF_NONE; |
574 | if (GNUNET_YES == etime_is_rel) | 548 | if (GNUNET_YES == renew_token) |
575 | token_record.flags |= GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; | 549 | token_record.flags |= GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; |
576 | //Persist token | 550 | //Persist token |
577 | handle->ns_qe = GNUNET_NAMESTORE_records_store (handle->ns_handle, | 551 | handle->ns_qe = GNUNET_NAMESTORE_records_store (handle->ns_handle, |