diff options
author | Markus Voggenreiter <Markus.Voggenreiter@tum.de> | 2019-11-27 16:30:03 +0100 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2020-01-13 13:31:05 +0100 |
commit | 1267dec774294ec2dcc6d2b89bced85eb4fadaa7 (patch) | |
tree | 6a3aa5b7e587f420ea4552f0400f5085a38e7d9e /src/reclaim/plugin_rest_reclaim.c | |
parent | cb08bbcbefc98afe6b8c7600bb0dfb1241343cff (diff) | |
download | gnunet-1267dec774294ec2dcc6d2b89bced85eb4fadaa7.tar.gz gnunet-1267dec774294ec2dcc6d2b89bced85eb4fadaa7.zip |
JWT Parser Implemented
Diffstat (limited to 'src/reclaim/plugin_rest_reclaim.c')
-rw-r--r-- | src/reclaim/plugin_rest_reclaim.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/reclaim/plugin_rest_reclaim.c b/src/reclaim/plugin_rest_reclaim.c index 70defae3d..71c59ae90 100644 --- a/src/reclaim/plugin_rest_reclaim.c +++ b/src/reclaim/plugin_rest_reclaim.c | |||
@@ -1190,18 +1190,25 @@ parse_jwt (const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest, | |||
1190 | uint32_t type; | 1190 | uint32_t type; |
1191 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Parsing JWT attributes.\n"); | 1191 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Parsing JWT attributes.\n"); |
1192 | char *decoded_jwt; | 1192 | char *decoded_jwt; |
1193 | json_t *json_val; | ||
1194 | json_error_t *json_err = NULL; | ||
1193 | 1195 | ||
1194 | jwt_string = GNUNET_RECLAIM_ATTESTATION_value_to_string (attest->type, | 1196 | jwt_string = GNUNET_RECLAIM_ATTESTATION_value_to_string (attest->type, |
1195 | attest->data, | 1197 | attest->data, |
1196 | attest->data_size); | 1198 | attest->data_size); |
1197 | char *jwt_body = strtok (jwt_string, delim); | 1199 | char *jwt_body = strtok (jwt_string, delim); |
1198 | jwt_body = strtok (NULL, delim); | 1200 | jwt_body = strtok (NULL, delim); |
1199 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "JWT Body: %s\n", | 1201 | GNUNET_STRINGS_base64_decode(jwt_body, strlen(jwt_body), (void **) &decoded_jwt); |
1200 | jwt_body); | 1202 | json_val=json_loads(decoded_jwt, JSON_DECODE_ANY, json_err); |
1201 | 1203 | const char *key; | |
1202 | val_str = "String from JWT, which is stored under claim"; | 1204 | json_t *value; |
1205 | json_object_foreach(json_val, key, value) { | ||
1206 | if (0 == strcasecmp (key,claim)) | ||
1207 | { | ||
1208 | val_str=json_dumps(value, JSON_ENCODE_ANY); | ||
1209 | } | ||
1210 | } | ||
1203 | type_str = "String"; | 1211 | type_str = "String"; |
1204 | |||
1205 | type = GNUNET_RECLAIM_ATTRIBUTE_typename_to_number (type_str); | 1212 | type = GNUNET_RECLAIM_ATTRIBUTE_typename_to_number (type_str); |
1206 | if (GNUNET_SYSERR ==(GNUNET_RECLAIM_ATTRIBUTE_string_to_value (type,val_str, | 1213 | if (GNUNET_SYSERR ==(GNUNET_RECLAIM_ATTRIBUTE_string_to_value (type,val_str, |
1207 | (void **) &data, | 1214 | (void **) &data, |
@@ -1252,7 +1259,8 @@ attr_collect (void *cls, | |||
1252 | return; | 1259 | return; |
1253 | } | 1260 | } |
1254 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr2; | 1261 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr2; |
1255 | attr2 = parse_jwt (attest, reference->name); | 1262 | attr2 = parse_jwt (attest, reference->reference_value); |
1263 | attr2->name = reference->name; | ||
1256 | if (NULL == attr2) | 1264 | if (NULL == attr2) |
1257 | { | 1265 | { |
1258 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1266 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |