source: tests/example_scripts/wiki/ctxtQuery1.py @ bceef20

abac0-leakabac0-mei
Last change on this file since bceef20 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: 1005 bytes
Line 
1#!/usr/bin/env python
2"""
3ctxtQuery1.py
4"""
5import os
6
7import ABAC
8ctxt = ABAC.Context()
9
10a = ABAC.ID("A", 24 * 3600 * 365 * 20)
11b = ABAC.ID("B", 24 * 3600 * 365 * 20)
12c = ABAC.ID("C", 24 * 3600 * 365 * 20)
13
14attr = ABAC.Attribute(a, "friendly_admin", 24 * 3600 * 365 * 20)
15attr.role(a.keyid(), "friendly")
16attr.role(a.keyid(), "admin")
17attr.bake()
18
19ctxt.load_id_chunk(a.cert_chunk())
20ctxt.load_attribute_chunk(attr.cert_chunk())
21
22attr = ABAC.Attribute(a, "friendly", 24 * 3600 * 365 * 20)
23attr.principal(b.keyid()) 
24attr.bake()
25ctxt.load_attribute_chunk(attr.cert_chunk())
26
27
28attr = ABAC.Attribute(a, "admin", 24 * 3600 * 365 * 20)
29attr.principal(b.keyid())
30attr.bake()
31ctxt.load_attribute_chunk(attr.cert_chunk())
32
33attr = ABAC.Attribute(a, "admin", 24 * 3600 * 365 * 20)
34attr.principal(c.keyid())
35attr.bake()
36ctxt.load_attribute_chunk(attr.cert_chunk())
37
38# Same code as above to initialize the ids and load the context
39
40ok, proof = ctxt.query(a.keyid() + ".friendly_admin", b.keyid())
41
42print "ok? %d" %ok
Note: See TracBrowser for help on using the repository browser.