source: examples/python_tests/partial_proof_rt1/attr.py @ 20eaefe

mei_rt2mei_rt2_fix_1
Last change on this file since 20eaefe was da73657, checked in by Mei <mei@…>, 12 years ago

1) example for partial proof

  • Property mode set to 100755
File size: 4.7 KB
RevLine 
[da73657]1#!/usr/bin/env python
2
3"""
4See README in this directory for the semantics of the example.  This file
5constructs the credentials described and puts copies into this directory
6
7cmd1:env keystore=`pwd` ./attr.py
8"""
9import os
10import ABAC
11
12ctxt = ABAC.Context()
13print "ABAC version %s" % ctxt.version()
14
15acmeID=ABAC.ID("Acme_ID.pem");
16acmeID.id_load_privkey_file("Acme_private.pem");
17ctxt.load_id(acmeID)
18acme=acmeID.id_keyid()
19
20oshID=ABAC.ID("Osh_ID.pem");
21oshID.id_load_privkey_file("Osh_private.pem");
22ctxt.load_id(oshID)
23osh=oshID.id_keyid()
24
25burpeeID=ABAC.ID("Burpee_ID.pem");
26burpeeID.id_load_privkey_file("Burpee_private.pem");
27ctxt.load_id(burpeeID)
28burpee=burpeeID.id_keyid()
29
30coyoteID=ABAC.ID("Coyote_ID.pem");
31coyoteID.id_load_privkey_file("Coyote_private.pem");
32ctxt.load_id(coyoteID)
33coyote=coyoteID.id_keyid()
34
35ladybugID=ABAC.ID("Ladybug_ID.pem");
36ladybugID.id_load_privkey_file("Ladybug_private.pem");
37ctxt.load_id(ladybugID)
38ladybug=ladybugID.id_keyid()
39
40grannyID=ABAC.ID("Granny_ID.pem");
41grannyID.id_load_privkey_file("Granny_private.pem");
42ctxt.load_id(grannyID)
43granny=grannyID.id_keyid()
44
45poohID=ABAC.ID("Pooh_ID.pem");
46poohID.id_load_privkey_file("Pooh_private.pem");
47ctxt.load_id(poohID)
48pooh=poohID.id_keyid()
49
50################################################
51# Credential
52#[keyid:Acme].role:buy_rockets <- [keyid:Acme].role:preferred_customer
53head = ABAC.Role(acme,"buy_rockets")
54tail = ABAC.Role(acme,"preferred_customer")
55attr=ABAC.Attribute(head, 1800)
56attr.attribute_add_tail(tail)
57attr.attribute_bake()
58attr.attribute_write_cert("Acme_buy_rockets__Acme_preferred_customer_attr.der")
59
60#################################################
61# Credential
62#[keyid:Acme].role:preferred_customer <- [keyid:Coyote]
63head = ABAC.Role(acme,"preferred_customer")
64tail = ABAC.Role(coyote)
65attr=ABAC.Attribute(head, 1800)
66attr.attribute_add_tail(tail)
67attr.attribute_bake()
68attr.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
73head = ABAC.Role(acme,"buy_flowers")
74param=ABAC.DataTerm(burpeeID)
75head.role_add_data_term(param)
76tail = ABAC.Role(acme,"green_thumb")
77attr=ABAC.Attribute(head, 1800)
78attr.attribute_add_tail(tail)
79attr.attribute_bake()
80attr.attribute_write_cert("Acme_buy_flowers__Acme_green_thumb_attr.der")
81
82#################################################
83# Credential
84#[keyid:Acme].role:green_thumb <- [keyid:Ladybug]
85head = ABAC.Role(acme,"green_thumb")
86tail = ABAC.Role(ladybug)
87attr=ABAC.Attribute(head, 1800)
88attr.attribute_add_tail(tail)
89attr.attribute_bake()
90attr.attribute_write_cert("Acme_green_thumb__Ladybug_attr.der")
91
92#################################################
93# Credential
94#[keyid:Acme].role:green_thumb <- [keyid:Granny]
95head = ABAC.Role(acme,"green_thumb")
96tail = ABAC.Role(granny)
97attr=ABAC.Attribute(head, 1800)
98attr.attribute_add_tail(tail)
99attr.attribute_bake()
100attr.attribute_write_cert("Acme_green_thumb__Granny_attr.der")
101
102################################################
103# Credential
104#[keyid:Acme].role:buy_lumbers <- [keyid:Acme].role:contractor
105head = ABAC.Role(acme,"buy_lumbers")
106tail = ABAC.Role(acme,"contractor")
107attr=ABAC.Attribute(head, 1800)
108attr.attribute_add_tail(tail)
109attr.attribute_bake()
110attr.attribute_write_cert("Acme_buy_lumbers__Acme_contractor_attr.der")
111
112#################################################
113# Credential
114#[keyid:Acme].role:contractor <- [keyid:Granny]
115head = ABAC.Role(acme,"contractor")
116tail = ABAC.Role(granny)
117attr=ABAC.Attribute(head, 1800)
118attr.attribute_add_tail(tail)
119attr.attribute_bake()
120attr.attribute_write_cert("Acme_contractor__Granny_attr.der")
121
122################################################
123# Credential
124#[keyid:Osh].role:buy_rockets <- [keyid:Osh].role:preferred_customer
125head = ABAC.Role(osh,"buy_rockets")
126tail = ABAC.Role(osh,"preferred_customer")
127attr=ABAC.Attribute(head, 1800)
128attr.attribute_add_tail(tail)
129attr.attribute_bake()
130attr.attribute_write_cert("Osh_buy_rockets__Osh_preferred_customer_attr.der")
131
132#################################################
133# Credential
134#[keyid:Osh].role:preferred_customer <- [keyid:Ladybug]
135head = ABAC.Role(osh,"preferred_customer")
136tail = ABAC.Role(ladybug)
137attr=ABAC.Attribute(head, 1800)
138attr.attribute_add_tail(tail)
139attr.attribute_bake()
140attr.attribute_write_cert("Osh_preferred_customer__Ladybug_attr.der")
141
142#################################################
143# Credential
144#[keyid:Osh].role:preferred_customer <- [keyid:Coyote]
145head = ABAC.Role(osh,"preferred_customer")
146tail = ABAC.Role(coyote)
147attr=ABAC.Attribute(head, 1800)
148attr.attribute_add_tail(tail)
149attr.attribute_bake()
150attr.attribute_write_cert("Osh_preferred_customer__Coyote_attr.der")
151
Note: See TracBrowser for help on using the repository browser.