Ignore:
Timestamp:
05/24/12 16:23:21 (12 months ago)
Author:
Mei <mei@…>
Branches:
mei_rt2, mei_rt2_fix_1
Children:
7211a95
Parents:
6e8997e
git-author:
Mei <mei@…> (05/24/12 16:23:21)
git-committer:
Mei <mei@…> (05/24/12 16:23:21)
Message:

1) modify abac.hh and added abac_c.c to unify the c and c++ api

interface (almost)

2) add new API
3) tweak the tests
4) filling missing code for abac_verifier_load_attribute_cert_attribute

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libabac/abac_verifier.c

    r5110d42 r5d06689  
    2727 
    2828static int debug=0; 
     29  
     30/* from abac_attribute.c */ 
     31extern char *get_cred_encoding(abac_attribute_t *ptr); 
    2932 
    3033extern abac_aspect_t *abac_yy_get_rule_head_aspect(); 
     
    3437extern void abac_yy_free_rule_clauses(); 
    3538extern char *generate_pl_type_clause(char *, int); 
     39extern abac_list_t *generate_pl_clauses(abac_aspect_t *, abac_aspect_t *); 
    3640 
    3741extern void abac_print_aspect_string_with_condition(abac_aspect_t *role, FILE*); 
     
    665669/****************************************************************************/ 
    666670 
    667 static int _verify_valid_credential(certificate_t *cert, 
     671static int _verify_valid_credential_string(certificate_t *cert, 
    668672abac_credential_t **cred_ret, char *encoded_attr_string) 
    669673{ 
     
    738742 * Returns true only if the certificate is valid and is issued by the proper 
    739743 * authority. 
     744 * attribute string is parsed via yyparse call 
    740745 */ 
    741746static int _load_attribute_cert(certificate_t *cert, abac_credential_t **cred_ret) { 
     
    771776    } 
    772777 
    773     ret=_verify_valid_credential(cert,cred_ret,encoded_attr_string); 
     778    ret=_verify_valid_credential_string(cert,cred_ret,encoded_attr_string); 
    774779 
    775780    if(ret != ABAC_CERT_SUCCESS) { 
     
    790795/** 
    791796 * Load an attribute cert from a abac_attribute_t. 
    792  */ 
    793 int abac_verifier_load_attribute_cert_attribute(abac_attribute_t *attr, abac_credential_t **cred) { 
    794     // load the cert 
    795     certificate_t *cert = abac_attribute_cert(attr); 
    796     if (cert == NULL) 
    797         return ABAC_CERT_INVALID; 
    798     
    799     // XXX need to skip the parsing part  
    800     return _load_attribute_cert(cert, cred); 
     797 * attr should be all checked out before arriving here 
     798 */ 
     799int abac_verifier_load_attribute_cert_attribute(abac_attribute_t *ptr, abac_credential_t **cred_ret) { 
     800    // get the attr 
     801    abac_aspect_t *head=abac_attribute_head(ptr); 
     802    abac_aspect_t *tail=abac_attribute_tail(ptr); 
     803 
     804    // preprocess for constraint part 
     805    preprocess_pl_head(head); 
     806    preprocess_pl_tail(tail); 
     807 
     808/* XXX collect up type clauses, constraint clauses and 
     809   generate rule clauses */ 
     810    abac_list_t *clauses=generate_pl_clauses(head,tail); 
     811    char *encoded_attr_string=get_cred_encoding(ptr); 
     812 
     813    abac_credential_t *cred = abac_xmalloc(sizeof(abac_credential_t)); 
     814    cred->hashkeyid=abac_xstrdup(encoded_attr_string); 
     815    cred->attr=abac_attribute_dup(ptr); 
     816    cred->pl_clauses = clauses; 
     817    *cred_ret = cred; 
     818 
     819    // success, add the key to the map of certificates 
     820    HASH_ADD_KEYPTR(hh, attr_creds, cred->hashkeyid, strlen(cred->hashkeyid), cred); 
     821 
     822    assert(attr_hashkeyid_list); 
     823    abac_list_add(attr_hashkeyid_list, abac_xstrdup(cred->hashkeyid)); 
     824    return ABAC_CERT_SUCCESS; 
    801825} 
    802826 
Note: See TracChangeset for help on using the changeset viewer.