Index: examples/python_tests/partial_proof_rt1/README
===================================================================
--- examples/python_tests/partial_proof_rt1/README	(revision da736573573da179d232c5929bf29d356f62d270)
+++ examples/python_tests/partial_proof_rt1/README	(revision da736573573da179d232c5929bf29d356f62d270)
@@ -0,0 +1,45 @@
+#
+# 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,
+# Acme's buy_lumbers role is limited to those who is Acme's contractor,
+# and Osh's buy_rockets role includes all of Osh's preferred customers.
+# The setup.py creates the principals and the attr.py creates policy 
+# credentials.  
+#
+# partial_proof_rt1
+#
+# partial proof checking sequence in libabac 
+#    can pLadybug buy_rockets from pAcme ? (fact)
+#    can pLadybug What from pAcme ? (What)
+#    Who can buy_rockets from pAcme ? (Who)
+#    can pLadybug buy_rockets from Whom ? (whom)
+#    can pLadybug What from Whom ? (What_Whom)
+
+
+#[keyid:Acme].role:buy_rockets <- [keyid:Acme].role:preferred_customer 
+#[keyid:Acme].role:preferred_customer <- [keyid:Coyote]
+
+#[keyid:Acme].role:buy_flowers([keyid:Burpee]) <- [keyid:Acme].role:green_thumb 
+#[keyid:Acme].role:green_thumb <- [keyid:Ladybug]
+#[keyid:Acme].role:green_thumb <- [keyid:Granny]
+
+#[keyid:Acme].role:buy_lumbers <- [keyid:Acme].role:contractor
+#[keyid:Acme].role:contractor <- [keyid:Granny]
+
+#[keyid:Osh].role:buy_rockets <- [keyid:Osh].role:preferred_customer 
+#[keyid:Osh].role:preferred_customer <- [keyid:Ladybug]
+#[keyid:Osh].role:preferred_customer <- [keyid:Coyote]
+
+# trying quries with next_proof calls,
+# can coyote buy rockets from Acme ?
+# can ladybug buy rockets from Acme ?
+# can ladybug buy rockets from Osh ?
+# can ladybug buy lumbers from Acme ?
+# can pooh buy rockets from Osh ? 
+# can pooh buy rockets from Osh ? (with next_proof calls)
+# can ladybug buy flowers from Acme ?
+# can pooh buy flowers from Acme ?
+
Index: examples/python_tests/partial_proof_rt1/attr.py
===================================================================
--- examples/python_tests/partial_proof_rt1/attr.py	(revision da736573573da179d232c5929bf29d356f62d270)
+++ examples/python_tests/partial_proof_rt1/attr.py	(revision da736573573da179d232c5929bf29d356f62d270)
@@ -0,0 +1,151 @@
+#!/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()
+
+burpeeID=ABAC.ID("Burpee_ID.pem");
+burpeeID.id_load_privkey_file("Burpee_private.pem");
+ctxt.load_id(burpeeID)
+burpee=burpeeID.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()
+
+grannyID=ABAC.ID("Granny_ID.pem");
+grannyID.id_load_privkey_file("Granny_private.pem");
+ctxt.load_id(grannyID)
+granny=grannyID.id_keyid()
+
+poohID=ABAC.ID("Pooh_ID.pem");
+poohID.id_load_privkey_file("Pooh_private.pem");
+ctxt.load_id(poohID)
+pooh=poohID.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:Burpee]) <- [keyid:Acme].role:green_thumb
+head = ABAC.Role(acme,"buy_flowers")
+param=ABAC.DataTerm(burpeeID)
+head.role_add_data_term(param)
+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:Acme].role:green_thumb <- [keyid:Granny]
+head = ABAC.Role(acme,"green_thumb")
+tail = ABAC.Role(granny)
+attr=ABAC.Attribute(head, 1800)
+attr.attribute_add_tail(tail)
+attr.attribute_bake()
+attr.attribute_write_cert("Acme_green_thumb__Granny_attr.der")
+
+################################################
+# Credential 
+#[keyid:Acme].role:buy_lumbers <- [keyid:Acme].role:contractor
+head = ABAC.Role(acme,"buy_lumbers")
+tail = ABAC.Role(acme,"contractor")
+attr=ABAC.Attribute(head, 1800)
+attr.attribute_add_tail(tail)
+attr.attribute_bake()
+attr.attribute_write_cert("Acme_buy_lumbers__Acme_contractor_attr.der")
+
+#################################################
+# Credential
+#[keyid:Acme].role:contractor <- [keyid:Granny]
+head = ABAC.Role(acme,"contractor")
+tail = ABAC.Role(granny)
+attr=ABAC.Attribute(head, 1800)
+attr.attribute_add_tail(tail)
+attr.attribute_bake()
+attr.attribute_write_cert("Acme_contractor__Granny_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_rt1/dump_db.py
===================================================================
--- examples/python_tests/partial_proof_rt1/dump_db.py	(revision da736573573da179d232c5929bf29d356f62d270)
+++ examples/python_tests/partial_proof_rt1/dump_db.py	(revision da736573573da179d232c5929bf29d356f62d270)
@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+
+"""
+cmd2: env ABAC_CN=1 keystore=`pwd` ./dump_db.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_rt1/query.py
===================================================================
--- examples/python_tests/partial_proof_rt1/query.py	(revision da736573573da179d232c5929bf29d356f62d270)
+++ examples/python_tests/partial_proof_rt1/query.py	(revision da736573573da179d232c5929bf29d356f62d270)
@@ -0,0 +1,166 @@
+#!/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)
+
+def get_next(ctxt) :
+    while( 1 ) :
+        print ("\nnext proof:")
+        (success, out) = ctxt.next_proof()
+        if(success) :
+            for c in out:
+                print "%s <- %s" % (c.head_string(), c.tail_string())
+        else:
+            print("no more..\n")
+            return
+
+# 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()
+
+grannyID=ABAC.ID("Granny_ID.pem");
+granny=grannyID.id_keyid()
+
+poohID=ABAC.ID("Pooh_ID.pem");
+pooh=poohID.id_keyid()
+
+burpeeID=ABAC.ID("Burpee_ID.pem");
+burpee=burpeeID.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())
+
+#ctxt.set_no_partial_proof()
+
+##########################################################################
+# 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())
+get_next(ctxt)
+
+##########################################################################
+# 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())
+
+##########################################################################
+# can ladybug buy lumbers from Acme ?
+# role=[keyid:Acme].role:buy_lumbers
+# p =[keyid:ladybug]
+role = ABAC.Role(acme,"buy_lumbers")
+p = ABAC.Role(ladybug)
+print "\n===bad============ Acme.buy_lumbers <- Ladybug"
+out = ctxt.query(role, p)
+for c in out[1]:
+    print "%s <- %s" % (c.head_string(), c.tail_string())
+get_next(ctxt)
+
+##########################################################################
+# can pooh buy rockets from Osh ?
+# role=[keyid:Osh].role:buy_rockets
+# p =[keyid:pooh]
+role = ABAC.Role(osh,"buy_rockets")
+p = ABAC.Role(pooh)
+print "\n===bad============ Osh.buy_rockets <- Pooh"
+out = ctxt.query(role, p)
+for c in out[1]:
+    print "%s <- %s" % (c.head_string(), c.tail_string())
+
+##########################################################################
+# can pooh buy rockets from Osh ?
+# role=[keyid:Osh].role:buy_rockets
+# p =[keyid:pooh]
+role = ABAC.Role(osh,"buy_rockets")
+p = ABAC.Role(pooh)
+print "\n===bad============ Osh.buy_rockets <- Pooh"
+out = ctxt.query(role, p)
+for c in out[1]:
+    print "%s <- %s" % (c.head_string(), c.tail_string())
+get_next(ctxt)
+
+##########################################################################
+# can ladybug buy flowers from Acme ?
+# role=[keyid:Acme].role:buy_flowers
+# p =[keyid:ladybug]
+role = ABAC.Role(acme,"buy_flowers")
+param=ABAC.DataTerm(burpeeID)
+role.role_add_data_term(param)
+p = ABAC.Role(ladybug)
+print "\n===good============ Acme.buy_flowers(Burpee) <- Ladybug"
+out = ctxt.query(role, p)
+for c in out[1]:
+    print "%s <- %s" % (c.head_string(), c.tail_string())
+
+##########################################################################
+# can pooh buy flowers from Acme ?
+# role=[keyid:Acme].role:buy_flowers
+# p =[keyid:pooh]
+role = ABAC.Role(acme,"buy_flowers")
+param=ABAC.DataTerm(burpeeID)
+role.role_add_data_term(param)
+p = ABAC.Role(pooh)
+print "\n===bad============ Acme.buy_flowers(Burpee) <- Pooh"
+out = ctxt.query(role, p)
+for c in out[1]:
+    print "%s <- %s" % (c.head_string(), c.tail_string())
+get_next(ctxt)
+
+
Index: examples/python_tests/partial_proof_rt1/rocket.save
===================================================================
--- examples/python_tests/partial_proof_rt1/rocket.save	(revision da736573573da179d232c5929bf29d356f62d270)
+++ examples/python_tests/partial_proof_rt1/rocket.save	(revision da736573573da179d232c5929bf29d356f62d270)
@@ -0,0 +1,131 @@
+
+...final principal set...
+(pAcme,keyid,y) 
+(pBurpee,keyid,y) 
+(pCoyote,keyid,y) 
+(pGranny,keyid,y) 
+(pLadybug,keyid,y) 
+(pOsh,keyid,y) 
+(pPooh,keyid,y) 
+
+...final policy attribute set...
+pAcme.buy_flowers(pBurpee) <- pAcme.green_thumb
+pAcme.buy_lumbers <- pAcme.contractor
+pAcme.buy_rockets <- pAcme.preferred_customer
+pAcme.contractor <- pGranny
+pAcme.green_thumb <- pGranny
+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
+A partial proof(type:1)
+pAcme.green_thumb <- pLadybug
+
+next proof:
+A partial proof(type:3)
+pAcme.buy_rockets <- pAcme.preferred_customer
+pAcme.preferred_customer <- pCoyote
+
+next proof:
+A partial proof(type:4)
+pOsh.buy_rockets <- pOsh.preferred_customer
+pOsh.preferred_customer <- pLadybug
+
+next proof:
+A partial proof(type:5)
+pAcme.green_thumb <- pLadybug
+
+next proof:
+A partial proof(type:5)
+pOsh.buy_rockets <- pOsh.preferred_customer
+pOsh.preferred_customer <- pLadybug
+
+next proof:
+A partial proof(type:5)
+pOsh.preferred_customer <- pLadybug
+
+next proof:
+no more..
+
+
+===good============ Osh.buy_rockets <- Ladybug
+YAP query succeed
+pOsh.buy_rockets <- pOsh.preferred_customer
+pOsh.preferred_customer <- pLadybug
+
+===bad============ Acme.buy_lumbers <- Ladybug
+YAP query failed
+A partial proof(type:1)
+pAcme.green_thumb <- pLadybug
+
+next proof:
+A partial proof(type:3)
+pAcme.buy_lumbers <- pAcme.contractor
+pAcme.contractor <- pGranny
+
+next proof:
+A partial proof(type:5)
+pAcme.green_thumb <- pLadybug
+
+next proof:
+A partial proof(type:5)
+pOsh.buy_rockets <- pOsh.preferred_customer
+pOsh.preferred_customer <- pLadybug
+
+next proof:
+A partial proof(type:5)
+pOsh.preferred_customer <- pLadybug
+
+next proof:
+no more..
+
+
+===bad============ Osh.buy_rockets <- Pooh
+YAP query failed
+A partial proof(type:3)
+pOsh.buy_rockets <- pOsh.preferred_customer
+pOsh.preferred_customer <- pCoyote
+
+===bad============ Osh.buy_rockets <- Pooh
+YAP query failed
+A partial proof(type:3)
+pOsh.buy_rockets <- pOsh.preferred_customer
+pOsh.preferred_customer <- pCoyote
+
+next proof:
+A partial proof(type:3)
+pOsh.buy_rockets <- pOsh.preferred_customer
+pOsh.preferred_customer <- pLadybug
+
+next proof:
+no more..
+
+
+===good============ Acme.buy_flowers(Burpee) <- Ladybug
+YAP query succeed
+pAcme.buy_flowers(pBurpee) <- pAcme.green_thumb
+pAcme.green_thumb <- pLadybug
+
+===bad============ Acme.buy_flowers(Burpee) <- Pooh
+YAP query failed
+A partial proof(type:3)
+pAcme.buy_flowers(pBurpee) <- pAcme.green_thumb
+pAcme.green_thumb <- pGranny
+
+next proof:
+A partial proof(type:3)
+pAcme.buy_flowers(pBurpee) <- pAcme.green_thumb
+pAcme.green_thumb <- pLadybug
+
+next proof:
+no more..
+
Index: examples/python_tests/partial_proof_rt1/run_test
===================================================================
--- examples/python_tests/partial_proof_rt1/run_test	(revision da736573573da179d232c5929bf29d356f62d270)
+++ examples/python_tests/partial_proof_rt1/run_test	(revision da736573573da179d232c5929bf29d356f62d270)
@@ -0,0 +1,30 @@
+#!/bin/sh 
+
+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_rt1 test result differs!!!"
+    fi
+else
+    echo "   ERROR:partial_proof_rt1 test result differs!!!"
+fi
+
Index: examples/python_tests/partial_proof_rt1/setup.py
===================================================================
--- examples/python_tests/partial_proof_rt1/setup.py	(revision da736573573da179d232c5929bf29d356f62d270)
+++ examples/python_tests/partial_proof_rt1/setup.py	(revision da736573573da179d232c5929bf29d356f62d270)
@@ -0,0 +1,38 @@
+#!/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")
+
+burpee=ABAC.ID("Burpee", 0)
+burpee.id_write_cert("Burpee_ID.pem")
+burpee.id_write_privkey("Burpee_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")
+
+granny=ABAC.ID("Granny", 0)
+granny.id_write_cert("Granny_ID.pem")
+granny.id_write_privkey("Granny_private.pem")
+
+pooh=ABAC.ID("Pooh", 0)
+pooh.id_write_cert("Pooh_ID.pem")
+pooh.id_write_privkey("Pooh_private.pem")
