source: tests/example_scripts/wiki/ctxtQuery2.py @ 3c30b59

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

1) add in new refactored regression testing directory
2) undo the abac.hh/ABAC.hh api changes
3) merged with Ted's changes to attribute format/nickname/issuer processing

  • Property mode set to 100755
File size: 1.2 KB
Line 
1#!/usr/bin/env python
2"""
3ctxtQuery2.py
4"""
5import os
6import sys
7import ABAC
8
9ctxt = ABAC.Context()
10
11a = ABAC.ID("A", 24 * 3600 * 365 * 20)
12b = ABAC.ID("B", 24 * 3600 * 365 * 20)
13c = ABAC.ID("C", 24 * 3600 * 365 * 20)
14
15attr = ABAC.Attribute(a, "friendly_admin", 24 * 3600 * 365 * 20)
16attr.role(a.keyid(), "friendly")
17attr.role(a.keyid(), "admin")
18attr.bake()
19
20ctxt.load_id_chunk(a.cert_chunk())
21ctxt.load_attribute_chunk(attr.cert_chunk())
22
23attr = ABAC.Attribute(a, "friendly", 24 * 3600 * 365 * 20)
24attr.principal(b.keyid()) 
25attr.bake()
26ctxt.load_attribute_chunk(attr.cert_chunk())
27
28
29attr = ABAC.Attribute(a, "admin", 24 * 3600 * 365 * 20)
30attr.principal(b.keyid())
31attr.bake()
32ctxt.load_attribute_chunk(attr.cert_chunk())
33
34attr = ABAC.Attribute(a, "admin", 24 * 3600 * 365 * 20)
35attr.principal(c.keyid())
36attr.bake()
37ctxt.load_attribute_chunk(attr.cert_chunk())
38
39ok, proof = ctxt.query(a.keyid() + ".friendly_admin", b.keyid())
40
41if not ok:
42    sys.exit(1)
43
44for i, c in enumerate(proof):
45    print "%s <- %s" % (c.head().string(), c.tail().string())
46    open("./id%d.pem" % i, "w").write(c.issuer_cert())
47    open("./attr%d.xml" % i, "w").write(c.attribute_cert())
48
49print "ok? %d" %ok
50
51
Note: See TracBrowser for help on using the repository browser.