Index: examples/python_tests/Makefile
===================================================================
--- examples/python_tests/Makefile	(revision 315ab8d4647ad71730d235ee872bde4487938abe)
+++ examples/python_tests/Makefile	(revision 5d1b6dcc3aa9073e56f03f5fe64fcd509c5d488c)
@@ -1,5 +1,5 @@
 
 
-DIRECTORY= access_rt2 acme_friend_rt1 acme_rockets_intersection_rt0 acme_rockets_rt0 alice_rt1 alumni2_rt1 alumni3_rt1 alumni_rt1 balltime_rt2 evaluator_rt1 experiment_create_rt0 file_read_rt2 fruits_rt2 leader_rt1 payraise_rt1 acme_multi_rt0 experiment_multi_rt0 basic_id basic_attribute
+DIRECTORY= access_rt2 acme_friend_rt1 acme_rockets_intersection_rt0 acme_rockets_rt0 alice_rt1 alumni2_rt1 alumni3_rt1 alumni_rt1 balltime_rt2 evaluator_rt1 experiment_create_rt0 file_read_rt2 fruits_rt2 leader_rt1 payraise_rt1 acme_multi_rt0 experiment_multi_rt0 basic_id basic_attribute partial_proof_rt0
 
 .PHONY : runcheck clean 
Index: examples/python_tests/partial_proof_rt0/README
===================================================================
--- examples/python_tests/partial_proof_rt0/README	(revision 5d1b6dcc3aa9073e56f03f5fe64fcd509c5d488c)
+++ examples/python_tests/partial_proof_rt0/README	(revision 5d1b6dcc3aa9073e56f03f5fe64fcd509c5d488c)
@@ -0,0 +1,28 @@
+#
+# This setup is used to test partial proof part of libabac
+#
+# This example shows a very simple delegation of roles by Acme and Osh.
+# Acme's buy_rockets role includes all of Acme's preferred customers,
+# Acme's buy_flowers role includes all of Acme's green thumbed customers
+# and Osh's buy_rockets role includes all of Oash's preferred customers.
+# The setup.py creates the principals and the attr.py creates policy 
+# credentials.  
+#
+# osh_acme_rt0
+
+# Credential 1
+#[keyid:Acme].role:buy_rockets <- [keyid:Acme].role:preferred_customer 
+# Credential 2
+#[keyid:Acme].role:preferred_customer <- [keyid:Coyote]
+# Credential 3
+#[keyid:Acme].role:buy_flowers <- [keyid:Acme].role:green_thumb 
+# Credential 4
+#[keyid:Acme].role:green_thumb <- [keyid:Ladybug]
+
+# Credential 5
+#[keyid:Osh].role:buy_rockets <- [keyid:Osh].role:preferred_customer 
+# Credential 6
+#[keyid:Osh].role:preferred_customer <- [keyid:Ladybug]
+# Credential 7
+#[keyid:Osh].role:preferred_customer <- [keyid:Coyote]
+
Index: examples/python_tests/partial_proof_rt0/attr.py
===================================================================
--- examples/python_tests/partial_proof_rt0/attr.py	(revision 5d1b6dcc3aa9073e56f03f5fe64fcd509c5d488c)
+++ examples/python_tests/partial_proof_rt0/attr.py	(revision 5d1b6dcc3aa9073e56f03f5fe64fcd509c5d488c)
@@ -0,0 +1,104 @@
+#!/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")
+
Index: examples/python_tests/partial_proof_rt0/dump_db.py
===================================================================
--- examples/python_tests/partial_proof_rt0/dump_db.py	(revision 5d1b6dcc3aa9073e56f03f5fe64fcd509c5d488c)
+++ examples/python_tests/partial_proof_rt0/dump_db.py	(revision 5d1b6dcc3aa9073e56f03f5fe64fcd509c5d488c)
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+
+"""
+cmd1:env keystore=`pwd` ./query.py 
+cmd2: env ABAC_CN=1 keystore=`pwd` ./query.py
+
+"""
+
+import os
+import ABAC
+
+ctxt = ABAC.Context()
+
+# Keystore is the directory containing the principal credentials.
+# Load existing principals and/or policy credentials
+if (os.environ.has_key("keystore")) :
+    keystore=os.environ["keystore"]
+    ctxt.load_directory(keystore)
+else:
+    print("keystore is not set...")
+    exit(1)
+
+ctxt.dump_yap_db()
+
+
Index: examples/python_tests/partial_proof_rt0/query.py
===================================================================
--- examples/python_tests/partial_proof_rt0/query.py	(revision 5d1b6dcc3aa9073e56f03f5fe64fcd509c5d488c)
+++ examples/python_tests/partial_proof_rt0/query.py	(revision 5d1b6dcc3aa9073e56f03f5fe64fcd509c5d488c)
@@ -0,0 +1,81 @@
+#!/usr/bin/env python
+
+"""
+cmd1:env keystore=`pwd` ./query.py 
+cmd2: env ABAC_CN=1 keystore=`pwd` ./query.py
+
+"""
+
+import os
+import ABAC
+
+ctxt = ABAC.Context()
+
+# Keystore is the directory containing the principal credentials.
+# Load existing principals and/or policy credentials
+if (os.environ.has_key("keystore")) :
+    keystore=os.environ["keystore"]
+    ctxt.load_directory(keystore)
+else:
+    print("keystore is not set...")
+    exit(1)
+
+# retrieve principals' keyid value from local credential files
+acmeID=ABAC.ID("Acme_ID.pem");
+acme=acmeID.id_keyid()
+
+oshID=ABAC.ID("Osh_ID.pem");
+osh=oshID.id_keyid()
+
+coyoteID=ABAC.ID("Coyote_ID.pem");
+coyote=coyoteID.id_keyid()
+
+ladybugID=ABAC.ID("Ladybug_ID.pem");
+ladybug=ladybugID.id_keyid()
+
+##########################################################################
+# dump the loaded principals/policies
+#
+out = ctxt.context_principals()
+print "\n...final principal set..."
+for x in out[1]:
+    print "%s " % x.string()
+out = ctxt.context_credentials()
+print "\n...final policy attribute set..."
+for c in out[1]:
+    print "%s <- %s" % (c.head_string(), c.tail_string())
+
+##########################################################################
+# can coyote buy rockets from Acme ?
+# 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())
+
+##########################################################################
+# can ladybug buy rockets from Acme ?
+# role=[keyid:Acme].role:buy_rockets
+# p =[keyid:ladybug]
+role = ABAC.Role(acme,"buy_rockets")
+p = ABAC.Role(ladybug)
+print "\n===bad============ Acme.buy_rockets <- Ladybug"
+out = ctxt.query(role, p)
+for c in out[1]:
+    print "%s <- %s" % (c.head_string(), c.tail_string())
+
+##########################################################################
+# can ladybug buy rockets from Osh ?
+# role=[keyid:Osh].role:buy_rockets
+# p =[keyid:ladybug]
+role = ABAC.Role(osh,"buy_rockets")
+p = ABAC.Role(ladybug)
+print "\n===good============ Osh.buy_rockets <- Ladybug"
+out = ctxt.query(role, p)
+for c in out[1]:
+    print "%s <- %s" % (c.head_string(), c.tail_string())
+
+
Index: examples/python_tests/partial_proof_rt0/rocket.save
===================================================================
--- examples/python_tests/partial_proof_rt0/rocket.save	(revision 5d1b6dcc3aa9073e56f03f5fe64fcd509c5d488c)
+++ examples/python_tests/partial_proof_rt0/rocket.save	(revision 5d1b6dcc3aa9073e56f03f5fe64fcd509c5d488c)
@@ -0,0 +1,28 @@
+
+...final principal set...
+(pAcme,keyid,y) 
+(pCoyote,keyid,y) 
+(pLadybug,keyid,y) 
+(pOsh,keyid,y) 
+
+...final policy attribute set...
+pAcme.buy_flowers <- pAcme.green_thumb
+pAcme.buy_rockets <- pAcme.preferred_customer
+pAcme.green_thumb <- pLadybug
+pAcme.preferred_customer <- pCoyote
+pOsh.buy_rockets <- pOsh.preferred_customer
+pOsh.preferred_customer <- pCoyote
+pOsh.preferred_customer <- pLadybug
+
+===good============ Acme.buy_rockets <- Coyote
+YAP query succeed
+pAcme.buy_rockets <- pAcme.preferred_customer
+pAcme.preferred_customer <- pCoyote
+
+===bad============ Acme.buy_rockets <- Ladybug
+YAP query failed
+
+===good============ Osh.buy_rockets <- Ladybug
+YAP query succeed
+pOsh.buy_rockets <- pOsh.preferred_customer
+pOsh.preferred_customer <- pLadybug
Index: examples/python_tests/partial_proof_rt0/run_test
===================================================================
--- examples/python_tests/partial_proof_rt0/run_test	(revision 5d1b6dcc3aa9073e56f03f5fe64fcd509c5d488c)
+++ examples/python_tests/partial_proof_rt0/run_test	(revision 5d1b6dcc3aa9073e56f03f5fe64fcd509c5d488c)
@@ -0,0 +1,32 @@
+#!/bin/sh 
+
+rm -rf rockets.pl
+
+echo '---setup principals'
+env keystore=`pwd` ./setup.py 1>/dev/null 2>& 1
+
+echo '---setup attributes'
+env keystore=`pwd` ./attr.py 1>rocket.log 2>& 1
+
+echo '---run 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"
+       env keystore=`pwd` ABAC_CN=1 ./dump_db.py 1 > rockets.pl 2>/dev/null
+    else
+       echo "   ERROR:partial_proof_rt0 test result differs!!!"
+    fi
+else
+    echo "   ERROR:partial_proof_rt0 test result differs!!!"
+fi
+
Index: examples/python_tests/partial_proof_rt0/setup.py
===================================================================
--- examples/python_tests/partial_proof_rt0/setup.py	(revision 5d1b6dcc3aa9073e56f03f5fe64fcd509c5d488c)
+++ examples/python_tests/partial_proof_rt0/setup.py	(revision 5d1b6dcc3aa9073e56f03f5fe64fcd509c5d488c)
@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+
+"""
+See README for the semantics. 
+sets up 2 (Acme, Coyote, Ladybug) principal ID credentials
+"""
+import os
+import ABAC
+
+ctxt = ABAC.Context()
+
+acme=ABAC.ID("Acme", 0)
+acme.id_write_cert("Acme_ID.pem")
+acme.id_write_privkey("Acme_private.pem")
+
+osh=ABAC.ID("Osh", 0)
+osh.id_write_cert("Osh_ID.pem")
+osh.id_write_privkey("Osh_private.pem")
+
+coyote=ABAC.ID("Coyote", 0)
+coyote.id_write_cert("Coyote_ID.pem")
+coyote.id_write_privkey("Coyote_private.pem")
+
+ladybug=ABAC.ID("Ladybug", 0)
+ladybug.id_write_cert("Ladybug_ID.pem")
+ladybug.id_write_privkey("Ladybug_private.pem")
