Index: examples/python_tests/acme_rockets_rt0/README
===================================================================
--- examples/python_tests/acme_rockets_rt0/README	(revision 5f551d32ce8befe42bdd0b6cc9391e217749c595)
+++ examples/python_tests/acme_rockets_rt0/README	(revision 5f551d32ce8befe42bdd0b6cc9391e217749c595)
@@ -0,0 +1,34 @@
+#!/bin/sh
+#
+# The example makes use of 2 principals, Acme and Coyote.
+#
+# This example shows a very simple delegation of roles by Acme.  Acme's
+# buy_rockets role includes all of Acme's preferred customers.  The example
+# creates the principals and 2 credentials.  Credential 1 encodes the policy
+# that all of Acme's preferred customers can buy rockets from Acme and
+# Credential 2 defines the Coyote as an Acme preferred customer.
+
+# The ./run_query script issues queries to show that the Coyote is both a preferred
+# customer and can buy rockets.  Two invalid queries are also made, checking if
+# Acme is the Coyote's friend, which it isn't and whether a query about
+# something other than a principal works (it doesn't).
+
+# acme_rockets_rt0_typed
+
+creddy --generate --cn Acme
+creddy --generate --cn Coyote
+
+#[keyid:Acme].role:buy_rockets <- [keyid:Acme].role:preferred_customer 
+# Credential 1
+creddy --attribute \
+       --issuer Acme_ID.pem --key Acme_private.pem --role buy_rockets \
+       --subject-cert Acme_ID.pem --subject-role preferred_customer \
+       --out Acme_buy_rockets__Acme_preferred_customer_attr.der
+
+#[keyid:Acme].role:preferred_customer <- [keyid:Coyote]
+# Credential 2
+creddy --attribute \
+       --issuer Acme_ID.pem --key Acme_private.pem --role preferred_customer \
+       --subject-cert Coyote_ID.pem \
+       --out Acme_preferred_customer__Coyote_attr.der
+
Index: examples/python_tests/acme_rockets_rt0/attr.py
===================================================================
--- examples/python_tests/acme_rockets_rt0/attr.py	(revision 5f551d32ce8befe42bdd0b6cc9391e217749c595)
+++ examples/python_tests/acme_rockets_rt0/attr.py	(revision 5f551d32ce8befe42bdd0b6cc9391e217749c595)
@@ -0,0 +1,54 @@
+#!/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()
+##
Index: examples/python_tests/acme_rockets_rt0/query.py
===================================================================
--- examples/python_tests/acme_rockets_rt0/query.py	(revision 5f551d32ce8befe42bdd0b6cc9391e217749c595)
+++ examples/python_tests/acme_rockets_rt0/query.py	(revision 5f551d32ce8befe42bdd0b6cc9391e217749c595)
@@ -0,0 +1,77 @@
+#!/usr/bin/env python
+
+"""
+  to test with python
+
+cmd1:env keystore=`pwd` ./query.py 
+cmd2: env ABAC_CN=1 keystore=`pwd` ./query.py
+
+"""
+
+import os
+import ABAC
+
+ctxt = ABAC.Context()
+
+# print "ABAC version %s" % ctxt.version()
+
+keystore=os.environ["keystore"]
+
+ctxt.load_directory(keystore)
+
+acmeID=ABAC.ID("Acme_ID.pem");
+acmeID.id_load_privkey_file("Acme_private.pem");
+acme=acmeID.id_keyid()
+
+coyoteID=ABAC.ID("Coyote_ID.pem");
+coyoteID.id_load_privkey_file("Coyote_private.pem");
+coyote=coyoteID.id_keyid()
+
+##########################################################################
+# role=[keyid:Acme].role:preferred_customer
+# p =[keyid:coyote]
+role = ABAC.Role(acme,"preferred_customer")
+p = ABAC.Role(coyote)
+print "\n===good============ Acme.preferred_customer <- Coyote"
+out = ctxt.query(role, p)
+for c in out[1]:
+    print "%s <- %s" % (c.head_string(), c.tail_string())
+
+##########################################################################
+# role=[keyid:Acme].role:buy_rockets
+# p =[keyid:coyote]
+role = ABAC.Role(acme,"buy_rockets")
+p = ABAC.Role(coyote)
+print "\n===good============ Acme.buy_rockets <- Coyote"
+out = ctxt.query(role, p)
+for c in out[1]:
+    print "%s <- %s" % (c.head_string(), c.tail_string())
+
+
+##########################################################################
+# role=[keyid:Coyote].role:friend
+# p=[keyid:Acme] 
+role = ABAC.Role(coyote,"friend")
+p = ABAC.Role(acme)
+print "\n===bad=============== Coyote.friend <- Acme"
+out = ctxt.query(role, p)
+for c in out[1]:
+    print "%s <- %s" % (c.head_string(), c.tail_string())
+
+
+##########################################################################
+# dump the loaded principals/policies
+#
+out = ctxt.context_principals()
+print "\n...final principal set..."
+for x in out[1]:
+    print "%s " % x.string()
+print "\n"
+out = ctxt.context_credentials()
+print "\n...final policy attribute set..."
+for c in out[1]:
+    print "%s <- %s" % (c.head_string(), c.tail_string())
+print "\n"
+
+
+
Index: examples/python_tests/acme_rockets_rt0/rocket.save
===================================================================
--- examples/python_tests/acme_rockets_rt0/rocket.save	(revision 5f551d32ce8befe42bdd0b6cc9391e217749c595)
+++ examples/python_tests/acme_rockets_rt0/rocket.save	(revision 5f551d32ce8befe42bdd0b6cc9391e217749c595)
@@ -0,0 +1,25 @@
+% Restoring file /usr/local/lib/Yap/startup.yss
+
+===good============ Acme.preferred_customer <- Coyote
+YAP query succeed
+pAcme.preferred_customer <- pCoyote
+
+===good============ Acme.buy_rockets <- Coyote
+YAP query succeed
+pAcme.buy_rockets <- pAcme.preferred_customer
+pAcme.preferred_customer <- pCoyote
+
+===bad=============== Coyote.friend <- Acme
+YAP query failed
+
+...final principal set...
+(pAcme,keyid,y) 
+(pCoyote,keyid,y) 
+
+
+
+...final policy attribute set...
+pAcme.buy_rockets <- pAcme.preferred_customer
+pAcme.preferred_customer <- pCoyote
+
+
Index: examples/python_tests/acme_rockets_rt0/run_test
===================================================================
--- examples/python_tests/acme_rockets_rt0/run_test	(revision 5f551d32ce8befe42bdd0b6cc9391e217749c595)
+++ examples/python_tests/acme_rockets_rt0/run_test	(revision 5f551d32ce8befe42bdd0b6cc9391e217749c595)
@@ -0,0 +1,35 @@
+#!/bin/sh 
+
+ABAC_PROVER_PATH="/home/mei/Deter/abac/libabac"
+export ABAC_PROVER_PATH
+
+echo '---setup principals'
+env keystore=`pwd` ./setup.py 1>/dev/null 2>& 1
+
+echo '---setup attributes'
+env keystore=`pwd` ./attr.py 1>/dev/null 2>& 1
+
+echo '---run queries'
+
+# Make prover queries
+g_cmd_sha=`grep "cmd1:" query.py |sed "s/cmd1://g" `
+g_cmd_cn=`grep "cmd2:" query.py |sed "s/cmd2://g" `
+
+echo '...with sha'
+eval $g_cmd_sha 2>/dev/null 1 > rocket.sha
+
+echo '...with cn'
+eval $g_cmd_cn 1>rocket.cn 2>&1
+
+result=`diff rocket.cn rocket.save 2>/dev/null`
+if [ $? -eq 0 ]; then
+    if [ "$result" = "" ]; then
+       echo "   PASSED"
+    else
+       echo "   ERROR:acme_rockets_rt0 test result differs!!!"
+    fi
+else
+    echo "   ERROR:acme_rockets_rt0 test result differs!!!"
+fi
+
+
Index: examples/python_tests/acme_rockets_rt0/setup.py
===================================================================
--- examples/python_tests/acme_rockets_rt0/setup.py	(revision 5f551d32ce8befe42bdd0b6cc9391e217749c595)
+++ examples/python_tests/acme_rockets_rt0/setup.py	(revision 5f551d32ce8befe42bdd0b6cc9391e217749c595)
@@ -0,0 +1,21 @@
+#!/usr/bin/env python
+
+"""
+  Setup 4 principal ID credentials
+
+  Acme, Coyote, WarnerBros and Batman
+
+"""
+import os
+import ABAC
+
+ctxt = ABAC.Context()
+
+alpha=ABAC.ID("Acme", 0)
+alpha.id_write_cert("Acme_ID.pem")
+alpha.id_write_privkey("Acme_private.pem")
+
+coyote=ABAC.ID("Coyote", 0)
+coyote.id_write_cert("Coyote_ID.pem")
+coyote.id_write_privkey("Coyote_private.pem")
+
