source: tests/scaling_tests/daisychain/likes_python/base/ATTR.py @ 6cd69a0

abac0-leakabac0-mei
Last change on this file since 6cd69a0 was ec550f7, checked in by Mei <mei@…>, 11 years ago

1) reworked how API doc is generated
2) tweak top level Makefile.am
3) loading issuer principal as side-effect of loading

an attribute credentials

4) add examples of GENI specific attribute credentials

and principal certificates into the regression testing

5) rename examples to tests

  • Property mode set to 100755
File size: 1.3 KB
Line 
1#!/usr/bin/env python
2
3"""
4See README in this directory for the semantics of the example.  This file
5constructs the credentials described and puts copies into this directory
6
7cmd1:env keystore=`pwd` ./attr.py
8"""
9
10import os
11import ABAC
12
13ctxt = ABAC.Context()
14
15# Keystore is the directory containing the principal credentials.
16# Load existing principals and/or policy credentials
17if (os.environ.has_key("keystore")) :
18    keystore=os.environ["keystore"]
19    ctxt.load_directory(keystore)
20else:
21    print("keystore is not set...")
22    exit(1)
23
24################################################
25# [keyid:john0].role:likes  <- [keyid:john0]
26a="John0_ID.pem"
27ap="John0_private.pem"
28f="John0_likes__John0_attr.xml" 
29   
30aID=ABAC.ID(a);
31aID.load_privkey(ap);
32aid=aID.keyid()
33
34attr = ABAC.Attribute(aID, "likes", 0)
35attr.principal(aid)
36attr.bake()
37attr.write_file(f)
38
39# [keyid:john1].role:likes  <- [keyid:john0].role:likes
40i=1
41while i <= #VAL#:
42    n=i-1
43
44    a="John%s_ID.pem"%i
45    ap="John%s_private.pem"%i
46    b="John%s_ID.pem"%n
47    f="John%s_likes__John%s_likes_attr.xml" %(i,n)
48   
49    aID=ABAC.ID(a);
50    aID.load_privkey(ap);
51    aid=aID.keyid()
52    bID=ABAC.ID(b);
53    bid=bID.keyid()
54
55    attr = ABAC.Attribute(aID,"likes", 0)
56    attr.role(bid,"likes")
57    attr.bake()
58    attr.write_file(f)
59    i=i+1
60
Note: See TracBrowser for help on using the repository browser.