#!/usr/bin/env python """ See README in this directory for the semantics of the example. This file constructs the credentials described and puts copies into this directory cmd1:env keystore=`pwd` ./attr.py """ import os import ABAC ctxt = ABAC.Context() print "ABAC version %s" % ctxt.version() acmeID=ABAC.ID("Acme_ID.pem"); acmeID.id_load_privkey_file("Acme_private.pem"); ctxt.load_id(acmeID) acme=acmeID.id_keyid() oshID=ABAC.ID("Osh_ID.pem"); oshID.id_load_privkey_file("Osh_private.pem"); ctxt.load_id(oshID) osh=oshID.id_keyid() coyoteID=ABAC.ID("Coyote_ID.pem"); coyoteID.id_load_privkey_file("Coyote_private.pem"); ctxt.load_id(coyoteID) coyote=coyoteID.id_keyid() ladybugID=ABAC.ID("Ladybug_ID.pem"); ladybugID.id_load_privkey_file("Ladybug_private.pem"); ctxt.load_id(ladybugID) ladybug=ladybugID.id_keyid() ################################################ # Credential #[keyid:Acme].role:buy_rockets <- [keyid:Acme].role:preferred_customer head = ABAC.Role(acme,"buy_rockets") tail = ABAC.Role(acme,"preferred_customer") attr=ABAC.Attribute(head, 1800) attr.attribute_add_tail(tail) attr.attribute_bake() attr.attribute_write_cert("Acme_buy_rockets__Acme_preferred_customer_attr.der") ################################################# # Credential #[keyid:Acme].role:preferred_customer <- [keyid:Coyote] head = ABAC.Role(acme,"preferred_customer") tail = ABAC.Role(coyote) attr=ABAC.Attribute(head, 1800) attr.attribute_add_tail(tail) attr.attribute_bake() attr.attribute_write_cert("Acme_preferred_customer__Coyote_attr.der") ################################################ # Credential #[keyid:Acme].role:buy_flowers <- [keyid:Acme].role:green_thumb head = ABAC.Role(acme,"buy_flowers") tail = ABAC.Role(acme,"green_thumb") attr=ABAC.Attribute(head, 1800) attr.attribute_add_tail(tail) attr.attribute_bake() attr.attribute_write_cert("Acme_buy_flowers__Acme_green_thumb_attr.der") ################################################# # Credential #[keyid:Acme].role:green_thumb <- [keyid:Ladybug] head = ABAC.Role(acme,"green_thumb") tail = ABAC.Role(ladybug) attr=ABAC.Attribute(head, 1800) attr.attribute_add_tail(tail) attr.attribute_bake() attr.attribute_write_cert("Acme_green_thumb__Ladybug_attr.der") ################################################ # Credential #[keyid:Osh].role:buy_rockets <- [keyid:Osh].role:preferred_customer head = ABAC.Role(osh,"buy_rockets") tail = ABAC.Role(osh,"preferred_customer") attr=ABAC.Attribute(head, 1800) attr.attribute_add_tail(tail) attr.attribute_bake() attr.attribute_write_cert("Osh_buy_rockets__Osh_preferred_customer_attr.der") ################################################# # Credential #[keyid:Osh].role:preferred_customer <- [keyid:Ladybug] head = ABAC.Role(osh,"preferred_customer") tail = ABAC.Role(ladybug) attr=ABAC.Attribute(head, 1800) attr.attribute_add_tail(tail) attr.attribute_bake() attr.attribute_write_cert("Osh_preferred_customer__Ladybug_attr.der") ################################################# # Credential #[keyid:Osh].role:preferred_customer <- [keyid:Coyote] head = ABAC.Role(osh,"preferred_customer") tail = ABAC.Role(coyote) attr=ABAC.Attribute(head, 1800) attr.attribute_add_tail(tail) attr.attribute_bake() attr.attribute_write_cert("Osh_preferred_customer__Coyote_attr.der")