source: examples/python_tests/partial_proof_rt0/attr.py @ 212e99f

mei_rt2mei_rt2_fix_1 libabac-0.2.2apre-partial
Last change on this file since 212e99f was a7f03f3, checked in by Mei <mei@…>, 12 years ago

1) add the new yap porting directory and some of code
2) add parital proof test code

  • Property mode set to 100755
File size: 3.2 KB
Line 
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
25coyoteID=ABAC.ID("Coyote_ID.pem");
26coyoteID.id_load_privkey_file("Coyote_private.pem");
27ctxt.load_id(coyoteID)
28coyote=coyoteID.id_keyid()
29
30ladybugID=ABAC.ID("Ladybug_ID.pem");
31ladybugID.id_load_privkey_file("Ladybug_private.pem");
32ctxt.load_id(ladybugID)
33ladybug=ladybugID.id_keyid()
34
35################################################
36# Credential
37#[keyid:Acme].role:buy_rockets <- [keyid:Acme].role:preferred_customer
38head = ABAC.Role(acme,"buy_rockets")
39tail = ABAC.Role(acme,"preferred_customer")
40attr=ABAC.Attribute(head, 1800)
41attr.attribute_add_tail(tail)
42attr.attribute_bake()
43attr.attribute_write_cert("Acme_buy_rockets__Acme_preferred_customer_attr.der")
44
45#################################################
46# Credential
47#[keyid:Acme].role:preferred_customer <- [keyid:Coyote]
48head = ABAC.Role(acme,"preferred_customer")
49tail = ABAC.Role(coyote)
50attr=ABAC.Attribute(head, 1800)
51attr.attribute_add_tail(tail)
52attr.attribute_bake()
53attr.attribute_write_cert("Acme_preferred_customer__Coyote_attr.der")
54
55################################################
56# Credential
57#[keyid:Acme].role:buy_flowers <- [keyid:Acme].role:green_thumb
58head = ABAC.Role(acme,"buy_flowers")
59tail = ABAC.Role(acme,"green_thumb")
60attr=ABAC.Attribute(head, 1800)
61attr.attribute_add_tail(tail)
62attr.attribute_bake()
63attr.attribute_write_cert("Acme_buy_flowers__Acme_green_thumb_attr.der")
64
65#################################################
66# Credential
67#[keyid:Acme].role:green_thumb <- [keyid:Ladybug]
68head = ABAC.Role(acme,"green_thumb")
69tail = ABAC.Role(ladybug)
70attr=ABAC.Attribute(head, 1800)
71attr.attribute_add_tail(tail)
72attr.attribute_bake()
73attr.attribute_write_cert("Acme_green_thumb__Ladybug_attr.der")
74
75################################################
76# Credential
77#[keyid:Osh].role:buy_rockets <- [keyid:Osh].role:preferred_customer
78head = ABAC.Role(osh,"buy_rockets")
79tail = ABAC.Role(osh,"preferred_customer")
80attr=ABAC.Attribute(head, 1800)
81attr.attribute_add_tail(tail)
82attr.attribute_bake()
83attr.attribute_write_cert("Osh_buy_rockets__Osh_preferred_customer_attr.der")
84
85#################################################
86# Credential
87#[keyid:Osh].role:preferred_customer <- [keyid:Ladybug]
88head = ABAC.Role(osh,"preferred_customer")
89tail = ABAC.Role(ladybug)
90attr=ABAC.Attribute(head, 1800)
91attr.attribute_add_tail(tail)
92attr.attribute_bake()
93attr.attribute_write_cert("Osh_preferred_customer__Ladybug_attr.der")
94
95#################################################
96# Credential
97#[keyid:Osh].role:preferred_customer <- [keyid:Coyote]
98head = ABAC.Role(osh,"preferred_customer")
99tail = ABAC.Role(coyote)
100attr=ABAC.Attribute(head, 1800)
101attr.attribute_add_tail(tail)
102attr.attribute_bake()
103attr.attribute_write_cert("Osh_preferred_customer__Coyote_attr.der")
104
Note: See TracBrowser for help on using the repository browser.