aboutsummaryrefslogtreecommitdiff
path: root/src/credential/plugin_rest_credential.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/credential/plugin_rest_credential.c')
-rw-r--r--src/credential/plugin_rest_credential.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/src/credential/plugin_rest_credential.c b/src/credential/plugin_rest_credential.c
index f6e4fc5a8..11e6fb276 100644
--- a/src/credential/plugin_rest_credential.c
+++ b/src/credential/plugin_rest_credential.c
@@ -193,12 +193,14 @@ attribute_delegation_to_json (struct GNUNET_CREDENTIAL_Delegation *delegation_ch
193 json_t *attr_obj; 193 json_t *attr_obj;
194 194
195 issuer = GNUNET_CRYPTO_ecdsa_public_key_to_string (&delegation_chain_entry->issuer_key); 195 issuer = GNUNET_CRYPTO_ecdsa_public_key_to_string (&delegation_chain_entry->issuer_key);
196 if (NULL == issuer)
196 { 197 {
197 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 198 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
198 "Issuer in delegation malformed\n"); 199 "Issuer in delegation malformed\n");
199 return NULL; 200 return NULL;
200 } 201 }
201 subject = GNUNET_CRYPTO_ecdsa_public_key_to_string (&delegation_chain_entry->subject_key); 202 subject = GNUNET_CRYPTO_ecdsa_public_key_to_string (&delegation_chain_entry->subject_key);
203 if (NULL == subject)
202 { 204 {
203 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 205 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
204 "Subject in credential malformed\n"); 206 "Subject in credential malformed\n");
@@ -207,16 +209,17 @@ attribute_delegation_to_json (struct GNUNET_CREDENTIAL_Delegation *delegation_ch
207 } 209 }
208 attr_obj = json_object (); 210 attr_obj = json_object ();
209 211
210 json_object_set_new (attr_obj, "subject", json_string (subject)); 212 json_object_set_new (attr_obj, "issuer", json_string (issuer));
211 json_object_set_new (attr_obj, "issuer", json_string (issuer));
212 json_object_set_new (attr_obj, "issuer_attribute", 213 json_object_set_new (attr_obj, "issuer_attribute",
213 json_string (delegation_chain_entry->issuer_attribute)); 214 json_string (delegation_chain_entry->issuer_attribute));
214 215
216 json_object_set_new (attr_obj, "subject", json_string (subject));
215 if (0 < delegation_chain_entry->subject_attribute_len) 217 if (0 < delegation_chain_entry->subject_attribute_len)
216 { 218 {
217 json_object_set_new (attr_obj, "subject_attribute", 219 json_object_set_new (attr_obj, "subject_attribute",
218 json_string (delegation_chain_entry->subject_attribute)); 220 json_string (delegation_chain_entry->subject_attribute));
219 } 221 }
222 GNUNET_free (issuer);
220 GNUNET_free (subject); 223 GNUNET_free (subject);
221 return attr_obj; 224 return attr_obj;
222} 225}
@@ -286,6 +289,8 @@ handle_verify_response (void *cls,
286 json_t *cred_array; 289 json_t *cred_array;
287 json_t *attr_array; 290 json_t *attr_array;
288 char *result; 291 char *result;
292 char *issuer;
293 char *id;
289 uint32_t i; 294 uint32_t i;
290 295
291 handle->verify_request = NULL; 296 handle->verify_request = NULL;
@@ -296,23 +301,33 @@ handle_verify_response (void *cls,
296 GNUNET_SCHEDULER_add_now (&do_error, handle); 301 GNUNET_SCHEDULER_add_now (&do_error, handle);
297 return; 302 return;
298 } 303 }
304 issuer = GNUNET_CRYPTO_ecdsa_public_key_to_string (&handle->issuer_key);
305 if (NULL == issuer)
306 {
307 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
308 "Issuer in delegation malformed\n");
309 return;
310 }
311 GNUNET_asprintf (&id,
312 "%s.%s",
313 issuer,
314 handle->issuer_attr);
315 GNUNET_free (issuer);
299 json_document = GNUNET_JSONAPI_document_new (); 316 json_document = GNUNET_JSONAPI_document_new ();
300 json_resource = GNUNET_JSONAPI_resource_new (GNUNET_REST_JSONAPI_CREDENTIAL_TYPEINFO, 317 json_resource = GNUNET_JSONAPI_resource_new (GNUNET_REST_JSONAPI_CREDENTIAL_TYPEINFO,
301 handle->issuer_attr); 318 id);
302 cred_obj = credential_to_json (cred); 319 GNUNET_free (id);
303 attr_array = json_array (); 320 attr_array = json_array ();
304 for (i = 0; i < d_count; i++) 321 for (i = 0; i < d_count; i++)
305 { 322 {
306 attr_obj = attribute_delegation_to_json (&delegation_chain[i]); 323 attr_obj = attribute_delegation_to_json (&delegation_chain[i]);
307 json_array_append (attr_array, attr_obj); 324 json_array_append_new (attr_array, attr_obj);
308 json_decref (attr_obj);
309 } 325 }
310 cred_array = json_array (); 326 cred_array = json_array ();
311 for (i=0;i<c_count;i++) 327 for (i=0;i<c_count;i++)
312 { 328 {
313 cred_obj = credential_to_json (&cred[i]); 329 cred_obj = credential_to_json (&cred[i]);
314 json_array_append (cred_array, cred_obj); 330 json_array_append_new (cred_array, cred_obj);
315 json_decref (cred_obj);
316 } 331 }
317 GNUNET_JSONAPI_resource_add_attr (json_resource, 332 GNUNET_JSONAPI_resource_add_attr (json_resource,
318 GNUNET_REST_JSONAPI_CREDENTIAL, 333 GNUNET_REST_JSONAPI_CREDENTIAL,