#!/usr/bin/env python """ Setup access policy attribute rules cmd1:env keystore=`pwd` ./attr.py """ import os import ABAC keystore=os.environ["keystore"] 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() coyoteID=ABAC.ID("Coyote_ID.pem"); coyoteID.id_load_privkey_file("Coyote_private.pem"); ctxt.load_id(coyoteID) coyote=coyoteID.id_keyid() ################################################ #[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") ctxt.load_attribute_file("Acme_buy_rockets__Acme_preferred_customer_attr.der") print attr.string() print attr.typed_string() print "\n" ################################################# #[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") ctxt.load_attribute_file("Acme_preferred_customer__Coyote_attr.der") print attr.string() print attr.typed_string() print "\n" ctxt.dump_yap_db() ##