diff options
Diffstat (limited to 'src/credential/plugin_rest_credential.c')
-rw-r--r-- | src/credential/plugin_rest_credential.c | 54 |
1 files changed, 26 insertions, 28 deletions
diff --git a/src/credential/plugin_rest_credential.c b/src/credential/plugin_rest_credential.c index 2e43139de..253378dfc 100644 --- a/src/credential/plugin_rest_credential.c +++ b/src/credential/plugin_rest_credential.c | |||
@@ -2,20 +2,18 @@ | |||
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2012-2016 GNUnet e.V. | 3 | Copyright (C) 2012-2016 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | it under the terms of the GNU General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with GNUnet; see the file COPYING. If not, write to the | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 17 | */ |
20 | /** | 18 | /** |
21 | * @author Martin Schanzenbach | 19 | * @author Martin Schanzenbach |
@@ -309,14 +307,14 @@ json_to_credential (json_t *res) | |||
309 | sig, | 307 | sig, |
310 | sizeof (struct GNUNET_CRYPTO_EcdsaSignature)); | 308 | sizeof (struct GNUNET_CRYPTO_EcdsaSignature)); |
311 | GNUNET_free (sig); | 309 | GNUNET_free (sig); |
312 | 310 | ||
313 | tmp = json_object_get (res, "expiration"); | 311 | tmp = json_object_get (res, "expiration"); |
314 | if (0 == json_is_integer (tmp)) | 312 | if (0 == json_is_integer (tmp)) |
315 | { | 313 | { |
316 | GNUNET_free (cred); | 314 | GNUNET_free (cred); |
317 | return NULL; | 315 | return NULL; |
318 | } | 316 | } |
319 | cred->expiration.abs_value_us = json_integer_value (tmp); | 317 | cred->expiration.abs_value_us = json_integer_value (tmp); |
320 | return cred; | 318 | return cred; |
321 | } | 319 | } |
322 | 320 | ||
@@ -342,7 +340,7 @@ credential_to_json (struct GNUNET_CREDENTIAL_Credential *cred) | |||
342 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 340 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
343 | "Issuer in credential malformed\n"); | 341 | "Issuer in credential malformed\n"); |
344 | return NULL; | 342 | return NULL; |
345 | } | 343 | } |
346 | subject = GNUNET_CRYPTO_ecdsa_public_key_to_string (&cred->subject_key); | 344 | subject = GNUNET_CRYPTO_ecdsa_public_key_to_string (&cred->subject_key); |
347 | if (NULL == subject) | 345 | if (NULL == subject) |
348 | { | 346 | { |
@@ -354,9 +352,9 @@ credential_to_json (struct GNUNET_CREDENTIAL_Credential *cred) | |||
354 | GNUNET_STRINGS_base64_encode ((char*)&cred->signature, | 352 | GNUNET_STRINGS_base64_encode ((char*)&cred->signature, |
355 | sizeof (struct GNUNET_CRYPTO_EcdsaSignature), | 353 | sizeof (struct GNUNET_CRYPTO_EcdsaSignature), |
356 | &signature); | 354 | &signature); |
357 | memcpy (attribute, | 355 | GNUNET_memcpy (attribute, |
358 | cred->issuer_attribute, | 356 | cred->issuer_attribute, |
359 | cred->issuer_attribute_len); | 357 | cred->issuer_attribute_len); |
360 | attribute[cred->issuer_attribute_len] = '\0'; | 358 | attribute[cred->issuer_attribute_len] = '\0'; |
361 | cred_obj = json_object (); | 359 | cred_obj = json_object (); |
362 | json_object_set_new (cred_obj, "issuer", json_string (issuer)); | 360 | json_object_set_new (cred_obj, "issuer", json_string (issuer)); |
@@ -570,7 +568,7 @@ collect_cred_cont (struct GNUNET_REST_RequestHandle *conndata_handle, | |||
570 | { | 568 | { |
571 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 569 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
572 | "Missing issuer attribute\n"); | 570 | "Missing issuer attribute\n"); |
573 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 571 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
574 | return; | 572 | return; |
575 | } | 573 | } |
576 | tmp = GNUNET_CONTAINER_multihashmap_get (conndata_handle->url_param_map, | 574 | tmp = GNUNET_CONTAINER_multihashmap_get (conndata_handle->url_param_map, |
@@ -585,7 +583,7 @@ collect_cred_cont (struct GNUNET_REST_RequestHandle *conndata_handle, | |||
585 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 583 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
586 | return; | 584 | return; |
587 | } | 585 | } |
588 | if (GNUNET_OK != | 586 | if (GNUNET_OK != |
589 | GNUNET_CRYPTO_ecdsa_public_key_from_string (tmp, | 587 | GNUNET_CRYPTO_ecdsa_public_key_from_string (tmp, |
590 | strlen (tmp), | 588 | strlen (tmp), |
591 | &handle->issuer_key)) | 589 | &handle->issuer_key)) |
@@ -626,7 +624,7 @@ collect_cred_cont (struct GNUNET_REST_RequestHandle *conndata_handle, | |||
626 | { | 624 | { |
627 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 625 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
628 | "Malformed subject\n"); | 626 | "Malformed subject\n"); |
629 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 627 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
630 | return; | 628 | return; |
631 | } | 629 | } |
632 | handle->ego_lookup = GNUNET_IDENTITY_ego_lookup (cfg, | 630 | handle->ego_lookup = GNUNET_IDENTITY_ego_lookup (cfg, |
@@ -679,7 +677,7 @@ verify_cred_cont (struct GNUNET_REST_RequestHandle *conndata_handle, | |||
679 | { | 677 | { |
680 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 678 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
681 | "Missing issuer attribute\n"); | 679 | "Missing issuer attribute\n"); |
682 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 680 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
683 | return; | 681 | return; |
684 | } | 682 | } |
685 | tmp = GNUNET_CONTAINER_multihashmap_get (conndata_handle->url_param_map, | 683 | tmp = GNUNET_CONTAINER_multihashmap_get (conndata_handle->url_param_map, |
@@ -694,7 +692,7 @@ verify_cred_cont (struct GNUNET_REST_RequestHandle *conndata_handle, | |||
694 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 692 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
695 | return; | 693 | return; |
696 | } | 694 | } |
697 | if (GNUNET_OK != | 695 | if (GNUNET_OK != |
698 | GNUNET_CRYPTO_ecdsa_public_key_from_string (tmp, | 696 | GNUNET_CRYPTO_ecdsa_public_key_from_string (tmp, |
699 | strlen (tmp), | 697 | strlen (tmp), |
700 | &handle->issuer_key)) | 698 | &handle->issuer_key)) |
@@ -735,7 +733,7 @@ verify_cred_cont (struct GNUNET_REST_RequestHandle *conndata_handle, | |||
735 | { | 733 | { |
736 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 734 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
737 | "Malformed subject\n"); | 735 | "Malformed subject\n"); |
738 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 736 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
739 | return; | 737 | return; |
740 | } | 738 | } |
741 | if (GNUNET_OK != | 739 | if (GNUNET_OK != |
@@ -946,7 +944,7 @@ get_cred_issuer_cb (void *cls, | |||
946 | { | 944 | { |
947 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 945 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
948 | "Missing expiration\n"); | 946 | "Missing expiration\n"); |
949 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 947 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
950 | return; | 948 | return; |
951 | } | 949 | } |
952 | expiration_str = GNUNET_CONTAINER_multihashmap_get (handle->rest_handle->url_param_map, | 950 | expiration_str = GNUNET_CONTAINER_multihashmap_get (handle->rest_handle->url_param_map, |
@@ -955,7 +953,7 @@ get_cred_issuer_cb (void *cls, | |||
955 | { | 953 | { |
956 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 954 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
957 | "Expiration malformed\n"); | 955 | "Expiration malformed\n"); |
958 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 956 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
959 | return; | 957 | return; |
960 | } | 958 | } |
961 | 959 | ||
@@ -968,7 +966,7 @@ get_cred_issuer_cb (void *cls, | |||
968 | { | 966 | { |
969 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 967 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
970 | "Malformed expiration: %s\n", expiration_str); | 968 | "Malformed expiration: %s\n", expiration_str); |
971 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 969 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
972 | return; | 970 | return; |
973 | } | 971 | } |
974 | GNUNET_CRYPTO_hash (GNUNET_REST_JSONAPI_CREDENTIAL_ISSUER_ATTR, | 972 | GNUNET_CRYPTO_hash (GNUNET_REST_JSONAPI_CREDENTIAL_ISSUER_ATTR, |
@@ -980,10 +978,10 @@ get_cred_issuer_cb (void *cls, | |||
980 | { | 978 | { |
981 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 979 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
982 | "Missing issuer attribute\n"); | 980 | "Missing issuer attribute\n"); |
983 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 981 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
984 | return; | 982 | return; |
985 | } | 983 | } |
986 | handle->issuer_attr = GNUNET_strdup(GNUNET_CONTAINER_multihashmap_get | 984 | handle->issuer_attr = GNUNET_strdup(GNUNET_CONTAINER_multihashmap_get |
987 | (handle->rest_handle->url_param_map, | 985 | (handle->rest_handle->url_param_map, |
988 | &key)); | 986 | &key)); |
989 | GNUNET_CRYPTO_hash (GNUNET_REST_JSONAPI_CREDENTIAL_SUBJECT_KEY, | 987 | GNUNET_CRYPTO_hash (GNUNET_REST_JSONAPI_CREDENTIAL_SUBJECT_KEY, |
@@ -1004,7 +1002,7 @@ get_cred_issuer_cb (void *cls, | |||
1004 | { | 1002 | { |
1005 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1003 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1006 | "Malformed subject\n"); | 1004 | "Malformed subject\n"); |
1007 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 1005 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
1008 | return; | 1006 | return; |
1009 | } | 1007 | } |
1010 | if (GNUNET_OK != | 1008 | if (GNUNET_OK != |