Index: examples/python_tests/alumni_rt1/README
===================================================================
--- examples/python_tests/alumni_rt1/README	(revision 669b4810acfbeee6bdec4a2443a99b2994efedc8)
+++ examples/python_tests/alumni_rt1/README	(revision f824a9ec465246e1555b44ec89522ae2ad35c47e)
@@ -1,11 +1,11 @@
-#!/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 1955 through 1958 inclusive no matter what
-# major the principal had.  This policy is expressed in Credential 1.
+# This example shows an example of reasoning about a role's parameters with
+# a range constraint.  There are 4 principals StateU, Bob, Maryann, and Joe.
+# StateU wants to establish a  set of founding alum 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 1955 through 1958 inclusive no matter what major the 
+# principal had.  This policy is expressed in Credential 1.
 #
 # Credentials 2, 3, and 4 each assign a diploma credential to Bob (a 1960
@@ -13,78 +13,19 @@
 # psychology degree).
 #
-# The attached ./run_query file asks if each of these principals are favored
+# The query.py file asks if each of these principals are favored
 # alums and Joe and Maryann are.
 
-# alumni_rt1_typed
+# alumni_rt1
 
-# [keyid:stateU].role:foundingAlumni <-?- [keyid:Bob] (no)
-# [keyid:stateU].role:foundingAlumni <-?- [keyid:Maryann] (yes)
-# [keyid:stateU].role:foundingAlumni <-?- [keyid:Joe] (yes)
-
-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:[1955..1958]])"
-
-diploma_m="diploma([string:'mathmatics'],[integer:1960])"
-diploma_z="diploma([string:'zoology'],[integer:1955])"
-diploma_p="diploma([string:'psychology'],[integer:1956])"
-
+# Credential 1
 # [keyid:stateU].role:foundingAlumni 
 #                   <- [keyid:stateU].role:diploma([?], [integer:?Year:[1955..1958]])
-# 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
 
+# Credential 2
 # [keyid:stateU].role:diploma([string:'mathmatics'],[integer:1960]) <- [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
 
+# Credential 3
 # [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
 
+# Credential 4
 # [keyid:stateU].role:diploma([string:'psychology'],[integer:1956]) <- [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
-
-
-#####################################################################
-# stateU.foundingAlumni <- stateU.diploma(?, ?Year:[1955..1958])
-# [keyid:stateU].role:foundingAlumni 
-#                <- [keyid:stateU].role:diploma([?], [integer:?Year:[1955..1958]])
-# 
-# stateU.diploma(mathmatics,1960)<-bob
-# [keyid:stateU].role:diploma([string:'mathmatics'],[integer:1960]) <- [keyid:bob]
-# 
-# stateU.diploma(zoology,1955)<-joe
-# [keyid:stateU].role:diploma([string:'zoology'],[integer:1955]) <- [keyid:joe]
-#
-# stateU.diploma(psychology,1956)<-maryann
-# [keyid:stateU].role:diploma([string:'psychology'],[integer:1956]) <- [keyid:maryann]
-#
-# query,
-# stateU.foundingAlumni<-?-bob  bad
-# [keyid:stateU].role:foundingAlumni <- [keyid:bob]
-# 
-# stateU.foundingAlumni<-?-maryann  good
-# [keyid:stateU].role:foundingAlumni <- [keyid:maryann]
-#
Index: examples/python_tests/alumni_rt1/alumni.save
===================================================================
--- examples/python_tests/alumni_rt1/alumni.save	(revision 669b4810acfbeee6bdec4a2443a99b2994efedc8)
+++ examples/python_tests/alumni_rt1/alumni.save	(revision f824a9ec465246e1555b44ec89522ae2ad35c47e)
@@ -1,4 +1,16 @@
 % Restoring file /usr/local/lib/Yap/startup.yss
   
+...final principal set...
+(pBob,keyid,y) 
+(pJoe,keyid,y) 
+(pMaryann,keyid,y) 
+(pStateU,keyid,y) 
+
+...final policy attribute set...
+pStateU.diploma('mathmatics',1960) <- pBob
+pStateU.diploma('psychology',1956) <- pMaryann
+pStateU.diploma('zoology',1955) <- pJoe
+pStateU.foundingAlumni <- pStateU.diploma(_,Year:[1955 .. 1958])
+
 ===bad============ stateU.foundingAlumni <- Bob
 YAP query failed
@@ -13,18 +25,2 @@
 pStateU.foundingAlumni <- pStateU.diploma(_,Year:[1955 .. 1958])
 pStateU.diploma('zoology',1955) <- pJoe
-
-...final principal set...
-(pBob,keyid,y) 
-(pJoe,keyid,y) 
-(pMaryann,keyid,y) 
-(pStateU,keyid,y) 
-
-
-
-...final policy attribute set...
-pStateU.diploma('mathmatics',1960) <- pBob
-pStateU.diploma('psychology',1956) <- pMaryann
-pStateU.diploma('zoology',1955) <- pJoe
-pStateU.foundingAlumni <- pStateU.diploma(_,Year:[1955 .. 1958])
-
-
Index: examples/python_tests/alumni_rt1/attr.py
===================================================================
--- examples/python_tests/alumni_rt1/attr.py	(revision 669b4810acfbeee6bdec4a2443a99b2994efedc8)
+++ examples/python_tests/alumni_rt1/attr.py	(revision f824a9ec465246e1555b44ec89522ae2ad35c47e)
@@ -2,8 +2,8 @@
 
 """
-  Setup access policy attribute rules
+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 
-
 """
 
@@ -11,10 +11,12 @@
 import ABAC
 
-keystore=os.environ["keystore"]
-
 ctxt = ABAC.Context()
 print "ABAC version %s" % ctxt.version()
 
-ctxt.load_directory(keystore)
+# 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)
 
 out = ctxt.context_principals()
@@ -30,4 +32,5 @@
 print "\n"
 
+# retrieve principals' keyid value from local credential files
 stateUID=ABAC.ID("StateU_ID.pem")
 stateUID.id_load_privkey_file("StateU_private.pem")
@@ -48,11 +51,21 @@
 
 ################################################
+# Credential 1, the year is constrainted by a range constraint with min and max 
+#               values
 # [keyid:stateU].role:foundingAlumni
-#                   <- [keyid:stateU].role:diploma([?], [integer:?Year:[1955 .. 1958]])
+#          <- [keyid:stateU].role:diploma([?], [integer:?Year:[1955 .. 1958]])
 head = ABAC.Role(stateU,"foundingAlumni")
+
+# create an anonymous parameter that will take any type of major
 param1=ABAC.DataTerm("anonymous", "_")
+
+# initialize a constraint with integer type
 cond=ABAC.Constraint("integer")
+
+# set the bounding min and max value for this constraint
 cond.constraint_add_integer_min(1955)
 cond.constraint_add_integer_max(1958)
+
+# make the parameter with this integer constraint
 param2=ABAC.DataTerm("integer", "Year", cond)
 tail = ABAC.Role(stateU,"diploma")
@@ -60,7 +73,15 @@
 tail.role_add_data_term(param2)
 attr=ABAC.Attribute(head, 1800)
+
+# build up the policy
 attr.attribute_add_tail(tail)
+
+# finalize the policy
 attr.attribute_bake()
+
+# write the policy out into the file system
 attr.attribute_write_cert("StateU_foundingAlumni__stateU_diploma_q_qY_attr.der")
+
+# load this policy into the context using this external credential file
 ctxt.load_attribute_file("StateU_foundingAlumni__stateU_diploma_q_qY_attr.der")
 print attr.string() 
@@ -69,5 +90,7 @@
 
 #################################################
-# [keyid:stateU].role:diploma([string:'mathmatics'],[integer:1960]) <- [keyid:bob]
+# Credential 2
+# [keyid:stateU].role:diploma([string:'mathmatics'],[integer:1960]) 
+#                                                            <- [keyid:bob]
 param1=ABAC.DataTerm("string", "'mathmatics'")
 param2=ABAC.DataTerm("integer", "1960")
@@ -86,5 +109,7 @@
 
 #################################################
-# [keyid:stateU].role:diploma([string:'zoology'],[integer:1955]) <- [keyid:joe]
+# Credential 3
+# [keyid:stateU].role:diploma([string:'zoology'],[integer:1955]) 
+#                                                     <- [keyid:joe]
 param1=ABAC.DataTerm("string", "'zoology'")
 param2=ABAC.DataTerm("integer", "1955")
@@ -103,5 +128,7 @@
 
 #################################################
-# [keyid:stateU].role:diploma([string:'psychology'],[integer:1956]) <- [keyid:maryann]
+# Credential 4
+# [keyid:stateU].role:diploma([string:'psychology'],[integer:1956]) 
+#                                                   <- [keyid:maryann]
 param1=ABAC.DataTerm("string", "'psychology'")
 param2=ABAC.DataTerm("integer", "1956")
@@ -119,4 +146,2 @@
 print "\n"
 
-ctxt.dump_yap_db()
-##
Index: examples/python_tests/alumni_rt1/query.py
===================================================================
--- examples/python_tests/alumni_rt1/query.py	(revision 669b4810acfbeee6bdec4a2443a99b2994efedc8)
+++ examples/python_tests/alumni_rt1/query.py	(revision f824a9ec465246e1555b44ec89522ae2ad35c47e)
@@ -2,5 +2,5 @@
 
 """
-  to test with python
+Run the queries described in README
 
 cmd1:env keystore=`pwd` ./query.py 
@@ -14,10 +14,14 @@
 ctxt = ABAC.Context()
 
-# print "ABAC version %s" % ctxt.version()
+# 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)
 
-keystore=os.environ["keystore"]
-
-ctxt.load_directory(keystore)
-
+# retrieve principals' keyid value from local credential files
 stateUID=ABAC.ID("StateU_ID.pem")
 stateUID.id_load_privkey_file("StateU_private.pem")
@@ -37,4 +41,17 @@
 
 ##########################################################################
+# 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())
+
+##########################################################################
+# is bob a founding alumni of stateU ?
 # role=[keyid:stateU].role:foundingAlumni
 # p=[keyid:Bob] 
@@ -47,4 +64,5 @@
 
 ##########################################################################
+# is maryann a founding alumni of stateU ?
 # role=[keyid:stateU].role:foundingAlumni
 # p=[keyid:Maryann] 
@@ -57,4 +75,5 @@
 
 ##########################################################################
+# is joe a founding alumni of stateU ?
 # role=[keyid:stateU].role:foundingAlumni
 # p=[keyid:Joe] 
@@ -66,17 +85,2 @@
     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/alumni_rt1/run_test
===================================================================
--- examples/python_tests/alumni_rt1/run_test	(revision 669b4810acfbeee6bdec4a2443a99b2994efedc8)
+++ examples/python_tests/alumni_rt1/run_test	(revision f824a9ec465246e1555b44ec89522ae2ad35c47e)
@@ -1,6 +1,3 @@
 #!/bin/sh 
-
-ABAC_PROVER_PATH="/home/mei/Deter/abac/libabac"
-export ABAC_PROVER_PATH
 
 echo '---setup principals'
Index: examples/python_tests/alumni_rt1/setup.py
===================================================================
--- examples/python_tests/alumni_rt1/setup.py	(revision 669b4810acfbeee6bdec4a2443a99b2994efedc8)
+++ examples/python_tests/alumni_rt1/setup.py	(revision f824a9ec465246e1555b44ec89522ae2ad35c47e)
@@ -2,7 +2,8 @@
 
 """
-  Setup 4 principal ID credentials
+See README for the semantics.  This creates principals
+used by the example.
+"""
 
-"""
 import os
 import ABAC
