aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/reclaim/plugin_reclaim_credential_pabc.c82
1 files changed, 7 insertions, 75 deletions
diff --git a/src/reclaim/plugin_reclaim_credential_pabc.c b/src/reclaim/plugin_reclaim_credential_pabc.c
index 2f6b7b8c4..89acd9032 100644
--- a/src/reclaim/plugin_reclaim_credential_pabc.c
+++ b/src/reclaim/plugin_reclaim_credential_pabc.c
@@ -228,50 +228,6 @@ pabc_parse_attributes_p (void *cls,
228 return pabc_parse_attributes (cls, cred->data, cred->data_size); 228 return pabc_parse_attributes (cls, cred->data, cred->data_size);
229} 229}
230 230
231struct Finder
232{
233 const char* target;
234 char *result;
235};
236
237static void
238find_attr (char const *const key,
239 char const *const value,
240 void *ctx)
241{
242 struct Finder *fdr = ctx;
243 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
244 "Found `%s', looking for `%s'\n",
245 key, fdr->target);
246 if (0 == strcmp (key, fdr->target))
247 fdr->result = GNUNET_strdup (value);
248}
249
250
251
252/**
253 * Parse a pabc and return an attribute value.
254 *
255 * @param cls the plugin
256 * @param data the pabc credential data
257 * @param data_size the pabc credential size
258 * @param skey the attribute key to look for.
259 * @return a string, containing the isser
260 */
261char *
262pabc_get_attribute (void *cls,
263 const char *data,
264 size_t data_size,
265 const char *skey)
266{
267
268 struct Finder fdr;
269 memset (&fdr, 0, sizeof (fdr));
270 fdr.target = skey;
271 pabc_cred_inspect_credential (data, &find_attr, &fdr);
272 return fdr.result;
273}
274
275 231
276/** 232/**
277 * Parse a pabc and return the issuer 233 * Parse a pabc and return the issuer
@@ -301,22 +257,6 @@ pabc_get_issuer (void *cls,
301 * @param cred the pabc credential 257 * @param cred the pabc credential
302 * @return a string, containing the isser 258 * @return a string, containing the isser
303 */ 259 */
304char*
305pabc_get_issuer (void *cls,
306 const char *data,
307 size_t data_size)
308{
309 return pabc_get_attribute (cls, data, data_size, "issuer");
310}
311
312
313/**
314 * Parse a pabc and return the issuer
315 *
316 * @param cls the plugin
317 * @param cred the pabc credential
318 * @return a string, containing the isser
319 */
320char * 260char *
321pabc_get_issuer_c (void *cls, 261pabc_get_issuer_c (void *cls,
322 const struct GNUNET_RECLAIM_Credential *cred) 262 const struct GNUNET_RECLAIM_Credential *cred)
@@ -351,27 +291,19 @@ pabc_get_issuer_p (void *cls,
351 * @param cred the pabc credential 291 * @param cred the pabc credential
352 * @return a string, containing the isser 292 * @return a string, containing the isser
353 */ 293 */
354int 294enum GNUNET_GenericReturnValue
355pabc_get_expiration (void *cls, 295pabc_get_expiration (void *cls,
356 const char *data, 296 const char *data,
357 size_t data_size, 297 size_t data_size,
358 struct GNUNET_TIME_Absolute *exp) 298 struct GNUNET_TIME_Absolute *exp)
359{ 299{
360 json_t *json_root; 300 char *exp_str;
361 json_t *json_attrs; 301 uint64_t exp_i;
362 json_t *value; 302
363 json_t *exp_j; 303 if (PABC_OK != pabc_cred_get_attr_by_name_from_cred (data,
364 json_error_t *json_err = NULL; 304 "expiration",
365 const char*key; 305 &exp_str))
366
367 json_root = json_loads (data, JSON_DECODE_ANY, json_err);
368 if ((NULL == json_root) ||
369 (! json_is_object (json_root)))
370 {
371 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
372 "Unable to retrive expiration from credential\n");
373 return GNUNET_SYSERR; 306 return GNUNET_SYSERR;
374 }
375 307
376 if (1 != sscanf (exp_str, "%llu", &exp_i)) 308 if (1 != sscanf (exp_str, "%llu", &exp_i))
377 { 309 {