1 | #!/usr/bin/env python |
---|
2 | |
---|
3 | """ |
---|
4 | See README in this directory for the semantics of the example. This file |
---|
5 | constructs the credentials described and puts copies into this directory |
---|
6 | |
---|
7 | cmd1:env keystore=`pwd` ./attr.py |
---|
8 | """ |
---|
9 | import os |
---|
10 | import ABAC |
---|
11 | |
---|
12 | ctxt = ABAC.Context() |
---|
13 | print "ABAC version %s" % ctxt.version() |
---|
14 | |
---|
15 | acmeID=ABAC.ID("Acme_ID.pem"); |
---|
16 | acmeID.id_load_privkey_file("Acme_private.pem"); |
---|
17 | ctxt.load_id(acmeID) |
---|
18 | acme=acmeID.id_keyid() |
---|
19 | |
---|
20 | oshID=ABAC.ID("Osh_ID.pem"); |
---|
21 | oshID.id_load_privkey_file("Osh_private.pem"); |
---|
22 | ctxt.load_id(oshID) |
---|
23 | osh=oshID.id_keyid() |
---|
24 | |
---|
25 | coyoteID=ABAC.ID("Coyote_ID.pem"); |
---|
26 | coyoteID.id_load_privkey_file("Coyote_private.pem"); |
---|
27 | ctxt.load_id(coyoteID) |
---|
28 | coyote=coyoteID.id_keyid() |
---|
29 | |
---|
30 | ladybugID=ABAC.ID("Ladybug_ID.pem"); |
---|
31 | ladybugID.id_load_privkey_file("Ladybug_private.pem"); |
---|
32 | ctxt.load_id(ladybugID) |
---|
33 | ladybug=ladybugID.id_keyid() |
---|
34 | |
---|
35 | ################################################ |
---|
36 | # Credential |
---|
37 | #[keyid:Acme].role:buy_rockets <- [keyid:Acme].role:preferred_customer |
---|
38 | head = ABAC.Role(acme,"buy_rockets") |
---|
39 | tail = ABAC.Role(acme,"preferred_customer") |
---|
40 | attr=ABAC.Attribute(head, 1800) |
---|
41 | attr.attribute_add_tail(tail) |
---|
42 | attr.attribute_bake() |
---|
43 | attr.attribute_write_cert("Acme_buy_rockets__Acme_preferred_customer_attr.der") |
---|
44 | |
---|
45 | ################################################# |
---|
46 | # Credential |
---|
47 | #[keyid:Acme].role:preferred_customer <- [keyid:Coyote] |
---|
48 | head = ABAC.Role(acme,"preferred_customer") |
---|
49 | tail = ABAC.Role(coyote) |
---|
50 | attr=ABAC.Attribute(head, 1800) |
---|
51 | attr.attribute_add_tail(tail) |
---|
52 | attr.attribute_bake() |
---|
53 | attr.attribute_write_cert("Acme_preferred_customer__Coyote_attr.der") |
---|
54 | |
---|
55 | ################################################ |
---|
56 | # Credential |
---|
57 | #[keyid:Acme].role:buy_flowers <- [keyid:Acme].role:green_thumb |
---|
58 | head = ABAC.Role(acme,"buy_flowers") |
---|
59 | tail = ABAC.Role(acme,"green_thumb") |
---|
60 | attr=ABAC.Attribute(head, 1800) |
---|
61 | attr.attribute_add_tail(tail) |
---|
62 | attr.attribute_bake() |
---|
63 | attr.attribute_write_cert("Acme_buy_flowers__Acme_green_thumb_attr.der") |
---|
64 | |
---|
65 | ################################################# |
---|
66 | # Credential |
---|
67 | #[keyid:Acme].role:green_thumb <- [keyid:Ladybug] |
---|
68 | head = ABAC.Role(acme,"green_thumb") |
---|
69 | tail = ABAC.Role(ladybug) |
---|
70 | attr=ABAC.Attribute(head, 1800) |
---|
71 | attr.attribute_add_tail(tail) |
---|
72 | attr.attribute_bake() |
---|
73 | attr.attribute_write_cert("Acme_green_thumb__Ladybug_attr.der") |
---|
74 | |
---|
75 | ################################################ |
---|
76 | # Credential |
---|
77 | #[keyid:Osh].role:buy_rockets <- [keyid:Osh].role:preferred_customer |
---|
78 | head = ABAC.Role(osh,"buy_rockets") |
---|
79 | tail = ABAC.Role(osh,"preferred_customer") |
---|
80 | attr=ABAC.Attribute(head, 1800) |
---|
81 | attr.attribute_add_tail(tail) |
---|
82 | attr.attribute_bake() |
---|
83 | attr.attribute_write_cert("Osh_buy_rockets__Osh_preferred_customer_attr.der") |
---|
84 | |
---|
85 | ################################################# |
---|
86 | # Credential |
---|
87 | #[keyid:Osh].role:preferred_customer <- [keyid:Ladybug] |
---|
88 | head = ABAC.Role(osh,"preferred_customer") |
---|
89 | tail = ABAC.Role(ladybug) |
---|
90 | attr=ABAC.Attribute(head, 1800) |
---|
91 | attr.attribute_add_tail(tail) |
---|
92 | attr.attribute_bake() |
---|
93 | attr.attribute_write_cert("Osh_preferred_customer__Ladybug_attr.der") |
---|
94 | |
---|
95 | ################################################# |
---|
96 | # Credential |
---|
97 | #[keyid:Osh].role:preferred_customer <- [keyid:Coyote] |
---|
98 | head = ABAC.Role(osh,"preferred_customer") |
---|
99 | tail = ABAC.Role(coyote) |
---|
100 | attr=ABAC.Attribute(head, 1800) |
---|
101 | attr.attribute_add_tail(tail) |
---|
102 | attr.attribute_bake() |
---|
103 | attr.attribute_write_cert("Osh_preferred_customer__Coyote_attr.der") |
---|
104 | |
---|