Index: examples/python_tests/alumni2_rt1/README
===================================================================
--- examples/python_tests/alumni2_rt1/README	(revision 5f551d32ce8befe42bdd0b6cc9391e217749c595)
+++ examples/python_tests/alumni2_rt1/README	(revision 5f551d32ce8befe42bdd0b6cc9391e217749c595)
@@ -0,0 +1,69 @@
+#!/bin/sh
+#
+# This example shows an example of reasoning about a role's parameters.  There
+# are 4 principals StateU, Bob, Maryann, and Joe.  StateU wants to establish a
+# set of founding alumni based on the year of graduation.  On graduation each
+# alum has previously been issued a credential parameterized with their major
+# and graduation year.  StateU sets up a policy that says that a principal is a
+# founding alum if they graduated in 1960, 1961, or 1963 no matter what major
+# the principal had.  One assumes there was some kind of NCAA suspension in
+# 1962.  This policy is expressed in Credential 1.
+#
+# Credentials 2, 3, and 4 each assign a diploma credential to Bob (a 1961
+# mathematics degree), Joe (a 1955 zoology degree) and Maryann (a 1962
+# psychology degree).
+#
+# The attached ./run_query file asks if each of these principals are favored
+# alums, and only Bob is.
+
+# alumni2_rt1_typeD
+
+# [keyid:stateU].role:foundingAlumni <-?- [keyid:Bob] (yes)
+# [keyid:stateU].role:foundingAlumni <-?- [keyid:Maryann] (no)
+# [keyid:stateU].role:foundingAlumni <-?- [keyid:Joe] (no)
+
+creddy --generate --cn StateU
+creddy --generate --cn Bob
+creddy --generate --cn Maryann
+creddy --generate --cn Joe
+
+stateU_keyid=`creddy --keyid --cert StateU_ID.pem`
+bob_keyid=`creddy --keyid --cert Bob_ID.pem`
+maryann_keyid=`creddy --keyid --cert Maryann_ID.pem`
+joe_keyid=`creddy --keyid --cert Joe_ID.pem`
+
+diploma_q_qY="diploma([?], [integer:?Year:[1960,1961,1963]])"
+
+diploma_m="diploma([string:'mathmatics'],[integer:1961])"
+diploma_z="diploma([string:'zoology'],[integer:1955])"
+diploma_p="diploma([string:'psychology'],[integer:1962])"
+
+# [keyid:stateU].role:foundingAlumni 
+#                   <- [keyid:stateU].role:diploma([?], [integer:?Year:[1960,1961,1963]])
+# Credential 1
+creddy --attribute \
+       --issuer StateU_ID.pem --key StateU_private.pem --role "foundingAlumni" \
+       --subject-cert StateU_ID.pem --subject-role "$diploma_q_qY" \
+       --out StateU_foundingAlumni__stateU_diploma_q_qY_attr.der
+
+# [keyid:stateU].role:diploma([string:'mathmatics'],[integer:1961]) <- [keyid:bob]
+# Credential 2
+creddy --attribute \
+        --issuer StateU_ID.pem --key StateU_private.pem --role "$diploma_m" \
+        --subject-cert Bob_ID.pem \
+        --out StateU_diploma_m__Bob_attr.der
+
+# [keyid:stateU].role:diploma([string:'zoology'],[integer:1955]) <- [keyid:joe]
+# Credential 3
+creddy --attribute \
+        --issuer StateU_ID.pem --key StateU_private.pem --role "$diploma_z" \
+        --subject-cert Joe_ID.pem \
+        --out StateU_diploma_m__Joe_attr.der
+
+# [keyid:stateU].role:diploma([string:'psychology'],[integer:1962]) <- [keyid:maryann]
+# Credential 4
+creddy --attribute \
+        --issuer StateU_ID.pem --key StateU_private.pem --role "$diploma_p" \
+        --subject-cert Maryann_ID.pem \
+        --out StateU_diploma_m__Maryann_attr.der
+
Index: examples/python_tests/alumni2_rt1/alumni2.save
===================================================================
--- examples/python_tests/alumni2_rt1/alumni2.save	(revision 5f551d32ce8befe42bdd0b6cc9391e217749c595)
+++ examples/python_tests/alumni2_rt1/alumni2.save	(revision 5f551d32ce8befe42bdd0b6cc9391e217749c595)
@@ -0,0 +1,28 @@
+% Restoring file /usr/local/lib/Yap/startup.yss
+
+===good============ stateU.foundingAlumni <- Bob
+YAP query succeed
+pStateU.foundingAlumni <- pStateU.diploma(_,Year:[1963,1961,1960])
+pStateU.diploma('mathmatics',1961) <- pBob
+
+===bad============ stateU.foundingAlumni <- Maryann
+YAP query failed
+
+===bad============ stateU.foundingAlumni <- Joe
+YAP query failed
+
+...final principal set...
+(pBob,keyid,y) 
+(pJoe,keyid,y) 
+(pMaryann,keyid,y) 
+(pStateU,keyid,y) 
+
+
+
+...final policy attribute set...
+pStateU.diploma('mathmatics',1961) <- pBob
+pStateU.diploma('psychology',1962) <- pMaryann
+pStateU.diploma('zoology',1955) <- pJoe
+pStateU.foundingAlumni <- pStateU.diploma(_,Year:[1963,1961,1960])
+
+
Index: examples/python_tests/alumni2_rt1/attr.py
===================================================================
--- examples/python_tests/alumni2_rt1/attr.py	(revision 5f551d32ce8befe42bdd0b6cc9391e217749c595)
+++ examples/python_tests/alumni2_rt1/attr.py	(revision 5f551d32ce8befe42bdd0b6cc9391e217749c595)
@@ -0,0 +1,123 @@
+#!/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()
+
+ctxt.load_directory(keystore)
+
+out = ctxt.context_principals()
+print "...initial principal set..."
+for x in out[1]:
+    print "%s " % x.string()
+print "\n" 
+
+out = ctxt.context_credentials()
+print "...initial policy attribute set..."
+for c in out[1]:
+    print "%s <- %s" % (c.head_string(), c.tail_string())
+print "\n"
+
+stateUID=ABAC.ID("StateU_ID.pem")
+stateUID.id_load_privkey_file("StateU_private.pem")
+stateU=stateUID.id_keyid()
+
+bobID=ABAC.ID("Bob_ID.pem")
+bobID.id_load_privkey_file("Bob_private.pem")
+bob=bobID.id_keyid()
+
+joeID=ABAC.ID("Joe_ID.pem")
+joeID.id_load_privkey_file("Joe_private.pem")
+joe=joeID.id_keyid()
+
+maryannID=ABAC.ID("Maryann_ID.pem")
+maryannID.id_load_privkey_file("Maryann_private.pem")
+maryann=maryannID.id_keyid()
+
+
+################################################
+# [keyid:stateU].role:foundingAlumni
+#                   <- [keyid:stateU].role:diploma([?], [integer:?Year:[1960,1961,1963]])
+head = ABAC.Role(stateU,"foundingAlumni")
+param1=ABAC.DataTerm("anonymous", "_")
+cond=ABAC.Constraint("integer")
+cond.constraint_add_integer_target(1960)
+cond.constraint_add_integer_target(1961)
+cond.constraint_add_integer_target(1963)
+param2=ABAC.DataTerm("integer", "Year", cond)
+tail = ABAC.Role(stateU,"diploma")
+tail.role_add_data_term(param1)
+tail.role_add_data_term(param2)
+attr=ABAC.Attribute(head, 1800)
+attr.attribute_add_tail(tail)
+attr.attribute_bake()
+attr.attribute_write_cert("StateU_foundingAlumni__stateU_diploma_q_qY_attr.der")
+ctxt.load_attribute_file("StateU_foundingAlumni__stateU_diploma_q_qY_attr.der")
+print attr.string() 
+print attr.typed_string()
+print "\n"
+
+#################################################
+# [keyid:stateU].role:diploma([string:'mathmatics'],[integer:1961]) <- [keyid:bob]
+param1=ABAC.DataTerm("string", "'mathmatics'")
+param2=ABAC.DataTerm("integer", "1961")
+head = ABAC.Role(stateU,"diploma")
+head.role_add_data_term(param1)
+head.role_add_data_term(param2)
+tail = ABAC.Role(bob)
+attr=ABAC.Attribute(head, 1800)
+attr.attribute_add_tail(tail)
+attr.attribute_bake()
+attr.attribute_write_cert("StateU_diploma_m__Bob_attr.der")
+ctxt.load_attribute_file("StateU_diploma_m__Bob_attr.der")
+print attr.string() 
+print attr.typed_string()
+print "\n"
+
+#################################################
+# [keyid:stateU].role:diploma([string:'zoology'],[integer:1955]) <- [keyid:joe]
+param1=ABAC.DataTerm("string", "'zoology'")
+param2=ABAC.DataTerm("integer", "1955")
+head = ABAC.Role(stateU,"diploma")
+head.role_add_data_term(param1)
+head.role_add_data_term(param2)
+tail = ABAC.Role(joe)
+attr=ABAC.Attribute(head, 1800)
+attr.attribute_add_tail(tail)
+attr.attribute_bake()
+attr.attribute_write_cert("StateU_diploma_z__Joe_attr.der")
+ctxt.load_attribute_file("StateU_diploma_z__Joe_attr.der")
+print attr.string() 
+print attr.typed_string()
+print "\n"
+
+#################################################
+# [keyid:stateU].role:diploma([string:'psychology'],[integer:1962]) <- [keyid:maryann]
+param1=ABAC.DataTerm("string", "'psychology'")
+param2=ABAC.DataTerm("integer", "1962")
+head = ABAC.Role(stateU,"diploma")
+head.role_add_data_term(param1)
+head.role_add_data_term(param2)
+tail = ABAC.Role(maryann)
+attr=ABAC.Attribute(head, 1800)
+attr.attribute_add_tail(tail)
+attr.attribute_bake()
+attr.attribute_write_cert("StateU_diploma_p__Maryann_attr.der")
+ctxt.load_attribute_file("StateU_diploma_p__Maryann_attr.der")
+print attr.string() 
+print attr.typed_string()
+print "\n"
+
+ctxt.dump_yap_db()
+##
Index: examples/python_tests/alumni2_rt1/query.py
===================================================================
--- examples/python_tests/alumni2_rt1/query.py	(revision 5f551d32ce8befe42bdd0b6cc9391e217749c595)
+++ examples/python_tests/alumni2_rt1/query.py	(revision 5f551d32ce8befe42bdd0b6cc9391e217749c595)
@@ -0,0 +1,82 @@
+#!/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)
+
+stateUID=ABAC.ID("StateU_ID.pem")
+stateUID.id_load_privkey_file("StateU_private.pem")
+stateU=stateUID.id_keyid()
+
+bobID=ABAC.ID("Bob_ID.pem")
+bobID.id_load_privkey_file("Bob_private.pem")
+bob=bobID.id_keyid()
+
+joeID=ABAC.ID("Joe_ID.pem")
+joeID.id_load_privkey_file("Joe_private.pem")
+joe=joeID.id_keyid()
+
+maryannID=ABAC.ID("Maryann_ID.pem")
+maryannID.id_load_privkey_file("Maryann_private.pem")
+maryann=maryannID.id_keyid()
+
+##########################################################################
+# role=[keyid:stateU].role:foundingAlumni
+# p=[keyid:Bob] 
+role = ABAC.Role(stateU,"foundingAlumni")
+p = ABAC.Role(bob)
+print "\n===good============ stateU.foundingAlumni <- Bob"
+out = ctxt.query(role, p)
+for c in out[1]:
+    print "%s <- %s" % (c.head_string(), c.tail_string())
+
+##########################################################################
+# role=[keyid:stateU].role:foundingAlumni
+# p=[keyid:Maryann] 
+role = ABAC.Role(stateU,"foundingAlumni")
+p = ABAC.Role(maryann)
+print "\n===bad============ stateU.foundingAlumni <- Maryann"
+out = ctxt.query(role, p)
+for c in out[1]:
+    print "%s <- %s" % (c.head_string(), c.tail_string())
+
+##########################################################################
+# role=[keyid:stateU].role:foundingAlumni
+# p=[keyid:Joe] 
+role = ABAC.Role(stateU,"foundingAlumni")
+p = ABAC.Role(joe)
+print "\n===bad============ stateU.foundingAlumni <- Joe"
+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/alumni2_rt1/run_test
===================================================================
--- examples/python_tests/alumni2_rt1/run_test	(revision 5f551d32ce8befe42bdd0b6cc9391e217749c595)
+++ examples/python_tests/alumni2_rt1/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 > alumni2.sha
+
+echo '...with cn'
+eval $g_cmd_cn 1>alumni2.cn 2>&1
+
+result=`diff alumni2.cn alumni2.save 2>/dev/null`
+if [ $? -eq 0 ]; then
+    if [ "$result" = "" ]; then
+       echo "   PASSED"
+    else
+       echo "   ERROR:alumni2_rt1 test result differs!!!"
+    fi
+else
+    echo "   ERROR:alumni2_rt1 test result differs!!!"
+fi
+
+
Index: examples/python_tests/alumni2_rt1/setup.py
===================================================================
--- examples/python_tests/alumni2_rt1/setup.py	(revision 5f551d32ce8befe42bdd0b6cc9391e217749c595)
+++ examples/python_tests/alumni2_rt1/setup.py	(revision 5f551d32ce8befe42bdd0b6cc9391e217749c595)
@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+
+"""
+  Setup 4 principal ID credentials
+
+"""
+import os
+import ABAC
+
+ctxt = ABAC.Context()
+
+stateU=ABAC.ID("StateU", 0)
+stateU.id_write_cert("StateU_ID.pem")
+stateU.id_write_privkey("StateU_private.pem")
+
+bob=ABAC.ID("Bob", 0)
+bob.id_write_cert("Bob_ID.pem")
+bob.id_write_privkey("Bob_private.pem")
+
+joe=ABAC.ID("Joe", 0)
+joe.id_write_cert("Joe_ID.pem")
+joe.id_write_privkey("Joe_private.pem")
+
+maryann=ABAC.ID("Maryann", 0)
+maryann.id_write_cert("Maryann_ID.pem")
+maryann.id_write_privkey("Maryann_private.pem")
+
+
