diff options
Diffstat (limited to 'src/reclaim/plugin_reclaim_credential_jwt.c')
-rw-r--r-- | src/reclaim/plugin_reclaim_credential_jwt.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/src/reclaim/plugin_reclaim_credential_jwt.c b/src/reclaim/plugin_reclaim_credential_jwt.c index c1e12f4a0..aac0a6ea5 100644 --- a/src/reclaim/plugin_reclaim_credential_jwt.c +++ b/src/reclaim/plugin_reclaim_credential_jwt.c | |||
@@ -160,6 +160,7 @@ jwt_parse_attributes (void *cls, | |||
160 | char *val_str = NULL; | 160 | char *val_str = NULL; |
161 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Parsing JWT attributes.\n"); | 161 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Parsing JWT attributes.\n"); |
162 | char *decoded_jwt; | 162 | char *decoded_jwt; |
163 | char *tmp; | ||
163 | json_t *json_val; | 164 | json_t *json_val; |
164 | json_error_t *json_err = NULL; | 165 | json_error_t *json_err = NULL; |
165 | 166 | ||
@@ -175,7 +176,10 @@ jwt_parse_attributes (void *cls, | |||
175 | json_val = json_loads (decoded_jwt, JSON_DECODE_ANY, json_err); | 176 | json_val = json_loads (decoded_jwt, JSON_DECODE_ANY, json_err); |
176 | GNUNET_free (decoded_jwt); | 177 | GNUNET_free (decoded_jwt); |
177 | const char *key; | 178 | const char *key; |
179 | const char *addr_key; | ||
178 | json_t *value; | 180 | json_t *value; |
181 | json_t *addr_value; | ||
182 | |||
179 | json_object_foreach (json_val, key, value) { | 183 | json_object_foreach (json_val, key, value) { |
180 | if (0 == strcmp ("iss", key)) | 184 | if (0 == strcmp ("iss", key)) |
181 | continue; | 185 | continue; |
@@ -189,12 +193,45 @@ jwt_parse_attributes (void *cls, | |||
189 | continue; | 193 | continue; |
190 | if (0 == strcmp ("aud", key)) | 194 | if (0 == strcmp ("aud", key)) |
191 | continue; | 195 | continue; |
196 | if (0 == strcmp ("address", key)) | ||
197 | { | ||
198 | if (!json_is_object(value)) { | ||
199 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
200 | "address claim in wrong format!"); | ||
201 | continue; | ||
202 | } | ||
203 | json_object_foreach (value, addr_key, addr_value) { | ||
204 | val_str = json_dumps (addr_value, JSON_ENCODE_ANY); | ||
205 | tmp = val_str; | ||
206 | //Remove leading " from jasson conversion | ||
207 | if (tmp[0] == '"') | ||
208 | tmp++; | ||
209 | //Remove trailing " from jansson conversion | ||
210 | if (tmp[strlen(tmp)-1] == '"') | ||
211 | tmp[strlen(tmp)-1] = '\0'; | ||
212 | GNUNET_RECLAIM_attribute_list_add (attrs, | ||
213 | addr_key, | ||
214 | NULL, | ||
215 | GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING, | ||
216 | tmp, | ||
217 | strlen (val_str)); | ||
218 | GNUNET_free (val_str); | ||
219 | } | ||
220 | continue; | ||
221 | } | ||
192 | val_str = json_dumps (value, JSON_ENCODE_ANY); | 222 | val_str = json_dumps (value, JSON_ENCODE_ANY); |
223 | tmp = val_str; | ||
224 | //Remove leading " from jasson conversion | ||
225 | if (tmp[0] == '"') | ||
226 | tmp++; | ||
227 | //Remove trailing " from jansson conversion | ||
228 | if (tmp[strlen(tmp)-1] == '"') | ||
229 | tmp[strlen(tmp)-1] = '\0'; | ||
193 | GNUNET_RECLAIM_attribute_list_add (attrs, | 230 | GNUNET_RECLAIM_attribute_list_add (attrs, |
194 | key, | 231 | key, |
195 | NULL, | 232 | NULL, |
196 | GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING,// FIXME | 233 | GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING,// FIXME |
197 | val_str, | 234 | tmp, |
198 | strlen (val_str)); | 235 | strlen (val_str)); |
199 | GNUNET_free (val_str); | 236 | GNUNET_free (val_str); |
200 | } | 237 | } |