source: examples/python_tests/acme_rockets_intersection_rt0/attr.py @ 5f551d3

mei_rt2mei_rt2_fix_1
Last change on this file since 5f551d3 was 7211a95, checked in by Mei <mei@…>, 12 years ago

1) add more python examples
2) add the missing linking role and linking oset api calls
3) fix the output of time typed data term/oset obj in typed_string format

(transform back from yap time format to our ddddddddTdddddd format

  • Property mode set to 100755
File size: 2.8 KB
Line 
1#!/usr/bin/env python
2
3"""
4  Setup access policy attribute rules
5
6cmd1:env keystore=`pwd` ./attr.py
7
8"""
9import os
10import ABAC
11
12keystore=os.environ["keystore"]
13
14ctxt = ABAC.Context()
15print "ABAC version %s" % ctxt.version()
16
17acmeID=ABAC.ID("Acme_ID.pem");
18acmeID.id_load_privkey_file("Acme_private.pem");
19ctxt.load_id(acmeID)
20acme=acmeID.id_keyid()
21
22coyoteID=ABAC.ID("Coyote_ID.pem");
23coyoteID.id_load_privkey_file("Coyote_private.pem");
24ctxt.load_id(coyoteID)
25coyote=coyoteID.id_keyid()
26
27warnerbrosID=ABAC.ID("WarnerBros_ID.pem");
28warnerbrosID.id_load_privkey_file("WarnerBros_private.pem");
29ctxt.load_id(warnerbrosID)
30warnerbros=warnerbrosID.id_keyid()
31
32batmanID=ABAC.ID("Batman_ID.pem");
33batmanID.id_load_privkey_file("Batman_private.pem");
34ctxt.load_id(batmanID)
35batman=batmanID.id_keyid()
36
37
38################################################
39#[keyid:Acme].role:buy_rockets <- [keyid:Acme].role:preferred_customer
40#                                    & [keyid:WarnerBros].role:charater
41head = ABAC.Role(acme,"buy_rockets")
42tail1 = ABAC.Role(acme,"preferred_customer")
43tail2 = ABAC.Role(warnerbros,"character")
44attr=ABAC.Attribute(head, 1800)
45attr.attribute_add_tail(tail1)
46attr.attribute_add_tail(tail2)
47attr.attribute_bake()
48attr.attribute_write_cert("Acme_buy_rockets__Acme_preferred_customer_and_WarnerBros_character_attr.der")
49ctxt.load_attribute_file("Acme_buy_rockets__Acme_preferred_customer_and_WarnerBros_character_attr.der")
50print attr.string() 
51print attr.typed_string()
52print "\n"
53
54#################################################
55#[keyid:Acme].role:preferred_customer <- [keyid:Coyote]
56head = ABAC.Role(acme,"preferred_customer")
57tail = ABAC.Role(coyote)
58attr=ABAC.Attribute(head, 1800)
59attr.attribute_add_tail(tail)
60attr.attribute_bake()
61attr.attribute_write_cert("Acme_preferred_customer__Coyote_attr.der")
62ctxt.load_attribute_file("Acme_preferred_customer__Coyote_attr.der")
63print attr.string() 
64print attr.typed_string()
65print "\n"
66
67#################################################
68#[keyid:Acme].role:preferred_customer <- [keyid:Batman]
69head = ABAC.Role(acme,"preferred_customer")
70tail = ABAC.Role(batman)
71attr=ABAC.Attribute(head,1800)
72attr.attribute_add_tail(tail)
73attr.attribute_bake()
74attr.attribute_write_cert("Acme_preferred_customer__Batman_attr.der")
75ctxt.load_attribute_file("Acme_preferred_customer__Batman_attr.der")
76print attr.string() 
77print attr.typed_string()
78print "\n"
79
80
81################################################
82#[keyid:WarnerBros].role:character <- [keyid:Coyote]
83head=ABAC.Role(warnerbros,"character")
84tail = ABAC.Role(coyote)
85attr=ABAC.Attribute(head, 1800)
86attr.attribute_add_tail(tail)
87attr.attribute_bake()
88attr.attribute_write_cert("WarnerBros_character__Coyote_attr.der")
89#ctxt.load_attribute_file("WarnerBros_character__Coyote_attr.der")
90ctxt.load_attribute(attr)
91#print attr.string()
92#print attr.typed_string()
93#print "\n"
94
95ctxt.dump_yap_db()
96##
Note: See TracBrowser for help on using the repository browser.