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 | burpeeID=ABAC.ID("Burpee_ID.pem"); |
---|
26 | burpeeID.id_load_privkey_file("Burpee_private.pem"); |
---|
27 | ctxt.load_id(burpeeID) |
---|
28 | burpee=burpeeID.id_keyid() |
---|
29 | |
---|
30 | coyoteID=ABAC.ID("Coyote_ID.pem"); |
---|
31 | coyoteID.id_load_privkey_file("Coyote_private.pem"); |
---|
32 | ctxt.load_id(coyoteID) |
---|
33 | coyote=coyoteID.id_keyid() |
---|
34 | |
---|
35 | ladybugID=ABAC.ID("Ladybug_ID.pem"); |
---|
36 | ladybugID.id_load_privkey_file("Ladybug_private.pem"); |
---|
37 | ctxt.load_id(ladybugID) |
---|
38 | ladybug=ladybugID.id_keyid() |
---|
39 | |
---|
40 | grannyID=ABAC.ID("Granny_ID.pem"); |
---|
41 | grannyID.id_load_privkey_file("Granny_private.pem"); |
---|
42 | ctxt.load_id(grannyID) |
---|
43 | granny=grannyID.id_keyid() |
---|
44 | |
---|
45 | poohID=ABAC.ID("Pooh_ID.pem"); |
---|
46 | poohID.id_load_privkey_file("Pooh_private.pem"); |
---|
47 | ctxt.load_id(poohID) |
---|
48 | pooh=poohID.id_keyid() |
---|
49 | |
---|
50 | ################################################ |
---|
51 | # Credential |
---|
52 | #[keyid:Acme].role:buy_rockets <- [keyid:Acme].role:preferred_customer |
---|
53 | head = ABAC.Role(acme,"buy_rockets") |
---|
54 | tail = ABAC.Role(acme,"preferred_customer") |
---|
55 | attr=ABAC.Attribute(head, 1800) |
---|
56 | attr.attribute_add_tail(tail) |
---|
57 | attr.attribute_bake() |
---|
58 | attr.attribute_write_cert("Acme_buy_rockets__Acme_preferred_customer_attr.der") |
---|
59 | |
---|
60 | ################################################# |
---|
61 | # Credential |
---|
62 | #[keyid:Acme].role:preferred_customer <- [keyid:Coyote] |
---|
63 | head = ABAC.Role(acme,"preferred_customer") |
---|
64 | tail = ABAC.Role(coyote) |
---|
65 | attr=ABAC.Attribute(head, 1800) |
---|
66 | attr.attribute_add_tail(tail) |
---|
67 | attr.attribute_bake() |
---|
68 | attr.attribute_write_cert("Acme_preferred_customer__Coyote_attr.der") |
---|
69 | |
---|
70 | ################################################ |
---|
71 | # Credential |
---|
72 | #[keyid:Acme].role:buy_flowers([keyid:Burpee]) <- [keyid:Acme].role:green_thumb |
---|
73 | head = ABAC.Role(acme,"buy_flowers") |
---|
74 | param=ABAC.DataTerm(burpeeID) |
---|
75 | head.role_add_data_term(param) |
---|
76 | tail = ABAC.Role(acme,"green_thumb") |
---|
77 | attr=ABAC.Attribute(head, 1800) |
---|
78 | attr.attribute_add_tail(tail) |
---|
79 | attr.attribute_bake() |
---|
80 | attr.attribute_write_cert("Acme_buy_flowers__Acme_green_thumb_attr.der") |
---|
81 | |
---|
82 | ################################################# |
---|
83 | # Credential |
---|
84 | #[keyid:Acme].role:green_thumb <- [keyid:Ladybug] |
---|
85 | head = ABAC.Role(acme,"green_thumb") |
---|
86 | tail = ABAC.Role(ladybug) |
---|
87 | attr=ABAC.Attribute(head, 1800) |
---|
88 | attr.attribute_add_tail(tail) |
---|
89 | attr.attribute_bake() |
---|
90 | attr.attribute_write_cert("Acme_green_thumb__Ladybug_attr.der") |
---|
91 | |
---|
92 | ################################################# |
---|
93 | # Credential |
---|
94 | #[keyid:Acme].role:green_thumb <- [keyid:Granny] |
---|
95 | head = ABAC.Role(acme,"green_thumb") |
---|
96 | tail = ABAC.Role(granny) |
---|
97 | attr=ABAC.Attribute(head, 1800) |
---|
98 | attr.attribute_add_tail(tail) |
---|
99 | attr.attribute_bake() |
---|
100 | attr.attribute_write_cert("Acme_green_thumb__Granny_attr.der") |
---|
101 | |
---|
102 | ################################################ |
---|
103 | # Credential |
---|
104 | #[keyid:Acme].role:buy_lumbers <- [keyid:Acme].role:contractor |
---|
105 | head = ABAC.Role(acme,"buy_lumbers") |
---|
106 | tail = ABAC.Role(acme,"contractor") |
---|
107 | attr=ABAC.Attribute(head, 1800) |
---|
108 | attr.attribute_add_tail(tail) |
---|
109 | attr.attribute_bake() |
---|
110 | attr.attribute_write_cert("Acme_buy_lumbers__Acme_contractor_attr.der") |
---|
111 | |
---|
112 | ################################################# |
---|
113 | # Credential |
---|
114 | #[keyid:Acme].role:contractor <- [keyid:Granny] |
---|
115 | head = ABAC.Role(acme,"contractor") |
---|
116 | tail = ABAC.Role(granny) |
---|
117 | attr=ABAC.Attribute(head, 1800) |
---|
118 | attr.attribute_add_tail(tail) |
---|
119 | attr.attribute_bake() |
---|
120 | attr.attribute_write_cert("Acme_contractor__Granny_attr.der") |
---|
121 | |
---|
122 | ################################################ |
---|
123 | # Credential |
---|
124 | #[keyid:Osh].role:buy_rockets <- [keyid:Osh].role:preferred_customer |
---|
125 | head = ABAC.Role(osh,"buy_rockets") |
---|
126 | tail = ABAC.Role(osh,"preferred_customer") |
---|
127 | attr=ABAC.Attribute(head, 1800) |
---|
128 | attr.attribute_add_tail(tail) |
---|
129 | attr.attribute_bake() |
---|
130 | attr.attribute_write_cert("Osh_buy_rockets__Osh_preferred_customer_attr.der") |
---|
131 | |
---|
132 | ################################################# |
---|
133 | # Credential |
---|
134 | #[keyid:Osh].role:preferred_customer <- [keyid:Ladybug] |
---|
135 | head = ABAC.Role(osh,"preferred_customer") |
---|
136 | tail = ABAC.Role(ladybug) |
---|
137 | attr=ABAC.Attribute(head, 1800) |
---|
138 | attr.attribute_add_tail(tail) |
---|
139 | attr.attribute_bake() |
---|
140 | attr.attribute_write_cert("Osh_preferred_customer__Ladybug_attr.der") |
---|
141 | |
---|
142 | ################################################# |
---|
143 | # Credential |
---|
144 | #[keyid:Osh].role:preferred_customer <- [keyid:Coyote] |
---|
145 | head = ABAC.Role(osh,"preferred_customer") |
---|
146 | tail = ABAC.Role(coyote) |
---|
147 | attr=ABAC.Attribute(head, 1800) |
---|
148 | attr.attribute_add_tail(tail) |
---|
149 | attr.attribute_bake() |
---|
150 | attr.attribute_write_cert("Osh_preferred_customer__Coyote_attr.der") |
---|
151 | |
---|