source: examples/python_tests/acme_rockets_rt0/attr.py @ 669b481

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

1) add more python examples

  • Property mode set to 100755
File size: 1.4 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
27################################################
28#[keyid:Acme].role:buy_rockets <- [keyid:Acme].role:preferred_customer
29head = ABAC.Role(acme,"buy_rockets")
30tail = ABAC.Role(acme,"preferred_customer")
31attr=ABAC.Attribute(head, 1800)
32attr.attribute_add_tail(tail)
33attr.attribute_bake()
34attr.attribute_write_cert("Acme_buy_rockets__Acme_preferred_customer_attr.der")
35ctxt.load_attribute_file("Acme_buy_rockets__Acme_preferred_customer_attr.der")
36print attr.string() 
37print attr.typed_string()
38print "\n"
39
40#################################################
41#[keyid:Acme].role:preferred_customer <- [keyid:Coyote]
42head = ABAC.Role(acme,"preferred_customer")
43tail = ABAC.Role(coyote)
44attr=ABAC.Attribute(head, 1800)
45attr.attribute_add_tail(tail)
46attr.attribute_bake()
47attr.attribute_write_cert("Acme_preferred_customer__Coyote_attr.der")
48ctxt.load_attribute_file("Acme_preferred_customer__Coyote_attr.der")
49print attr.string() 
50print attr.typed_string()
51print "\n"
52
53ctxt.dump_yap_db()
54##
Note: See TracBrowser for help on using the repository browser.