Index: examples/access_rt2_typed/bad_query.py
===================================================================
--- examples/access_rt2_typed/bad_query.py	(revision 9335cfa1f9ee260325c436b438f6063dfd4ec4e7)
+++ examples/access_rt2_typed/bad_query.py	(revision 9335cfa1f9ee260325c436b438f6063dfd4ec4e7)
@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+
+"""
+  to test with python
+
+cmd1:env keystore=`pwd` alpha=`creddy --keyid --cert Alpha_ID.pem` bob=`creddy --keyid --cert Bob_ID.pem` ./bad_query.py 
+cmd2: env ABAC_CN=1 keystore=`pwd` alpha=`creddy --keyid --cert Alpha_ID.pem` bob=`creddy --keyid --cert Bob_ID.pem` ./bad_query.py
+
+"""
+
+import os
+import ABAC
+
+ctxt = ABAC.Context()
+
+keystore=os.environ["keystore"]
+alpha=os.environ["alpha"]
+bob=os.environ["bob"]
+
+ctxt.load_directory(keystore)
+
+role ="[keyid:%s].role:access([string:'Read'],[urn:'file//badfileA'])" % alpha
+p = "[keyid:%s]" % bob
+
+out = ctxt.query(role, p)
+print out
+
+
Index: examples/access_rt2_typed/good_query.py
===================================================================
--- examples/access_rt2_typed/good_query.py	(revision 9335cfa1f9ee260325c436b438f6063dfd4ec4e7)
+++ examples/access_rt2_typed/good_query.py	(revision 9335cfa1f9ee260325c436b438f6063dfd4ec4e7)
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+
+"""
+  to test with python
+
+cmd1:env keystore=`pwd` alpha=`creddy --keyid --cert Alpha_ID.pem` bob=`creddy --keyid --cert Bob_ID.pem` ./good_query.py 
+cmd2: env ABAC_CN=1 keystore=`pwd` alpha=`creddy --keyid --cert Alpha_ID.pem` bob=`creddy --keyid --cert Bob_ID.pem` ./good_query.py
+
+"""
+
+import os
+import ABAC
+
+ctxt = ABAC.Context()
+
+keystore=os.environ["keystore"]
+alpha=os.environ["alpha"]
+bob=os.environ["bob"]
+
+ctxt.load_directory(keystore)
+
+role ="[keyid:%s].role:access([string:'Read'],[urn:'file//fileA'])" % alpha
+p = "[keyid:%s]" % bob
+
+out = ctxt.query(role, p)
+#print out
+
+for c in out[1]:
+    print "%s <- %s" % (c.head().string(), c.tail().string())
+
Index: examples/access_rt2_typed/query.py
===================================================================
--- examples/access_rt2_typed/query.py	(revision 01ab2b100136fa0f4580b854230a6fdd3115ed31)
+++ 	(revision )
@@ -1,31 +1,0 @@
-#!/usr/bin/env python
-
-"""
-  to test with python
-
-cmd1:env keystore=`pwd` alpha=`creddy --keyid --cert Alpha_ID.pem` bob=`creddy --keyid --cert Bob_ID.pem` ./query.py
-cmd2: env ABAC_CN=1 keystore=`pwd` alpha=`creddy --keyid --cert Alpha_ID.pem` bob=`creddy --keyid --cert Bob_ID.pem` ./query.py
-
-"""
-
-import os
-import ABAC
-
-ctxt = ABAC.Context()
-
-keystore=os.environ["keystore"]
-alpha=os.environ["alpha"]
-bob=os.environ["bob"]
-
-ctxt.load_directory(keystore)
-
-role ="[keyid:%s].role:access([string:'Read'],[urn:'file//fileA'])" % alpha
-p = "[keyid:%s]" % bob
-
-out = ctxt.query(role, p)
-print out
-
-for c in out[1]:
-    print "%s <- %s" % (c.head().string(), c.tail().string())
-
-
Index: examples/allout.save
===================================================================
--- examples/allout.save	(revision 01ab2b100136fa0f4580b854230a6fdd3115ed31)
+++ examples/allout.save	(revision 9335cfa1f9ee260325c436b438f6063dfd4ec4e7)
@@ -293,2 +293,19 @@
 YAP query failed
 prover failed!!
+
+ ==> RUN on payraise_rt1_typed
+YAP dump succeed
+ 
+===bad============ alpha.payRaise <- Joe
+YAP query failed
+prover failed!!
+ 
+===good============ alpha.payRaise <- Maryann
+YAP query succeed
+prover success!!
+credentials needed :
+ pAlpha.payRaise  <- pAlpha.evaluatorOf(This).goodPerformance & pAlpha.managerOf(This).niceCoworker 
+ pAlpha.evaluatorOf(pMaryann)  <- pBob 
+ pBob.goodPerformance  <- pMaryann 
+ pAlpha.managerOf(Z)  <- pAlpha.evaluatorOf(Z) 
+ pBob.niceCoworker  <- pMaryann 
Index: examples/experiment_create_rt0_typed/README
===================================================================
--- examples/experiment_create_rt0_typed/README	(revision 01ab2b100136fa0f4580b854230a6fdd3115ed31)
+++ examples/experiment_create_rt0_typed/README	(revision 9335cfa1f9ee260325c436b438f6063dfd4ec4e7)
@@ -7,5 +7,4 @@
 #
 #    Acme.experiment_create <- Acme.partner.experiment_create
-#    Acme.partner <- Globotron
 #
 #Globotron has delegated the authority to anyone an admin thinks is a
Index: examples/payraise_rt1_typed/README
===================================================================
--- examples/payraise_rt1_typed/README	(revision 9335cfa1f9ee260325c436b438f6063dfd4ec4e7)
+++ examples/payraise_rt1_typed/README	(revision 9335cfa1f9ee260325c436b438f6063dfd4ec4e7)
@@ -0,0 +1,125 @@
+#!/bin/sh
+
+#####################################################################
+# This example demostrates how to use 'this' as a data term of a RT1 
+# policy credential where it is implicitly translated to a variable.
+#
+# Credential 1 is the policy credential with 2 intersecting rules.
+# A employee is up for a pay raise if the evaluator of the employee 
+# affirms his/her good performance and the manager of the employee 
+# affirms his/her pleasantness.
+#
+# Credential 2 is the policy credential that states an evaluator of
+# an employee is also the manager of the employee.
+#
+# Credential 3, 4 and 5 state Bob is the evaluator of Maryann and she
+# is showing good performance and is a nice coworker. Credential 6 and
+# 7 state Bob is also the evaluator of Joe and he is showing good
+# performance. But, there is no fact that says Joe is a nice coworker.
+#
+# The attached ./run_query file asks if a given principal is
+# entitled to a pay raise. Maryann is but not Joe, because his manager
+# did not affirm his pleasantness(but neither did he deny it)
+
+rm -rf *der *pem
+
+# [keyid:Alpha].role:payRaise <-?- [keyid:Maryann] (yes)
+# [keyid:Alpha].role:payRaise <-?- [keyid:Joe] (no)
+
+creddy --generate --cn Alpha
+creddy --generate --cn Bob
+creddy --generate --cn Maryann
+creddy --generate --cn Joe
+
+alpha_keyid=`creddy --keyid --cert Alpha_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`
+
+performance_qT="evaluatorOf([principal:?this]).goodPerformance"
+niceguy_qT="managerOf([principal:?this]).niceCoworker"
+
+manager_qZ="managerOf([principal:?Z])"
+evaluator_qZ="evaluatorOf([principal:?Z])"
+
+evaluator_m="evaluatorOf([keyid:$maryann_keyid])"
+evaluator_j="evaluatorOf([keyid:$joe_keyid])"
+
+# [keyid:alpha].role:payRaise <-
+#           [keyid:alpha].role:evaluatorOf([principal:?this]).role:goodPerformance &
+#           [keyid:alpha].role:managerOf([principal:?this]).role:niceCoworker
+# Credential 1
+creddy --attribute \
+       --issuer Alpha_ID.pem --key Alpha_private.pem --role payRaise \
+       --subject-cert Alpha_ID.pem --subject-role "$performance_qT" \
+       --subject-cert Alpha_ID.pem --subject-role "$niceguy_qT" \
+       --out Alpha_payraise__Alpha_performance_qT_niceguy_qT_attr.der
+
+# [keyid:alpha].role:managerOf([principal:?Z])<-
+#           [keyid:alpha].role:evaluatorOf([principal:?Z])
+# Credential 2
+creddy --attribute \
+       --issuer Alpha_ID.pem --key Alpha_private.pem --role "$manager_qZ" \
+       --subject-cert Alpha_ID.pem --subject-role "$evaluator_qZ" \
+       --out Alpha_manager_qZ__Alpha_evaluator_qZ_attr.der
+
+# [keyid:alpha].role:evaluatorOf([keyid:Maryann]) <-[keyid:Bob]
+# Credential 3
+creddy --attribute \
+        --issuer Alpha_ID.pem --key Alpha_private.pem --role "$evaluator_m" \
+        --subject-cert Bob_ID.pem \
+        --out Alpha_evaluator_m__Bob_attr.der
+
+# [keyid:Bob].role:goodPerformance <- [keyid:Maryann])
+# Credential 4 
+creddy --attribute \
+        --issuer Bob_ID.pem --key Bob_private.pem --role goodPerformance \
+        --subject-cert Maryann_ID.pem \
+        --out Bob_goodperformance__Maryann_attr.der
+
+# [keyid:Bob].role:niceCoworker <- [keyid:Maryann])
+# Credential 5 
+creddy --attribute \
+        --issuer Bob_ID.pem --key Bob_private.pem --role niceCoworker \
+        --subject-cert Maryann_ID.pem \
+        --out Bob_niceworker__Maryann_attr.der
+
+# [keyid:alpha].role:evaluatorOf([keyid:Joe]) <-[keyid:Bob]
+# Credential 6
+creddy --attribute \
+        --issuer Alpha_ID.pem --key Alpha_private.pem --role "$evaluator_j" \
+        --subject-cert Bob_ID.pem \
+        --out Alpha_evaluator_j__Bob_attr.der
+
+# [keyid:Bob].role:goodPerformance <- [keyid:Joe])
+# Credential 7 
+creddy --attribute \
+        --issuer Bob_ID.pem --key Bob_private.pem --role goodPerformance \
+        --subject-cert Joe_ID.pem \
+        --out Bob_goodperformance__Joe_attr.der
+
+
+#####################################################################
+# 
+# alpha.payRaise <- alpha.evaluatorOf(this).goodPerformance & 
+#                   alpha.managerOf(this).niceCoworker
+# [keyid:alpha].role:payRaise <-
+#           [keyid:alpha].role:evaluatorOf([principal:?this]).role:goodPerformance &
+#           [keyid:alpha].role:managerOf([principal:?this]).role:niceCoworker
+#
+# alpha.managerOf(this) <- alpha.evaluatorOf(this)
+# [keyid:alpha].role:managerOf([principal:?this])<-
+#           [keyid:alpha].role:evaluatorOf([principal:?this])
+#
+# alpha.evaluatorOf(Maryann)<-Bob
+# [keyid:alpha].role:evaluatorOf([keyid:Maryann]) <-[keyid:Bob]
+# Bob.goodPerformance<-Maryann
+# [keyid:Bob].role:goodPerformance <- [keyid:Maryann])
+# Bob.niceCoworker<-Maryann
+# [keyid:Bob].role:niceCoworker <- [keyid:Maryann])
+#
+# alpha.evaluatorOf(Joe)<-Bob
+# [keyid:alpha].role:evaluatorOf([keyid:Joe]) <-[keyid:Bob]
+# Bob.goodPerformance<-Joe
+# [keyid:Bob].role:goodPerformance <- [keyid:Joe])
Index: examples/payraise_rt1_typed/run_query
===================================================================
--- examples/payraise_rt1_typed/run_query	(revision 9335cfa1f9ee260325c436b438f6063dfd4ec4e7)
+++ examples/payraise_rt1_typed/run_query	(revision 9335cfa1f9ee260325c436b438f6063dfd4ec4e7)
@@ -0,0 +1,37 @@
+
+# raise_rt1_typed
+
+pwd=`pwd`
+
+eloc=$pwd/../../libabac
+keyloc=$pwd
+
+alpha=`creddy --keyid --cert $keyloc/Alpha_ID.pem`
+
+bob=`creddy --keyid --cert $keyloc/Bob_ID.pem`
+maryann=`creddy --keyid --cert $keyloc/Maryann_ID.pem`
+joe=`creddy --keyid --cert $keyloc/Joe_ID.pem`
+
+alpha_payRaise="[keyid:$alpha].role:payRaise"
+
+bob_prin="[keyid:$bob]"
+maryann_prin="[keyid:$maryann]"
+joe_prin="[keyid:$joe]"
+
+# [keyid:alpha].role:payRaise <-?- [keyid:Maryann] (yes)
+# [keyid:alpha].role:payRaise <-?- [keyid:Joe] (yes) 
+
+## dump all credentials
+$eloc/abac_prover_yap  --keystore $keyloc --dump creds_dump
+
+# [keyid:alpha].role:payRaise <-?- [keyid:Joe] (no)
+echo " "
+echo "===bad============ alpha.payRaise <- Joe"
+$eloc/abac_prover_yap  --keystore $keyloc --role "$alpha_payRaise" --principal "$joe_prin"
+
+# [keyid:alpha].role:payRaise <-?- [keyid:Maryann] (yes)
+echo " "
+echo "===good============ alpha.payRaise <- Maryann"
+$eloc/abac_prover_yap  --keystore $keyloc --role "$alpha_payRaise" --principal "$maryann_prin"
+
+
Index: examples/runall
===================================================================
--- examples/runall	(revision 01ab2b100136fa0f4580b854230a6fdd3115ed31)
+++ examples/runall	(revision 9335cfa1f9ee260325c436b438f6063dfd4ec4e7)
@@ -3,6 +3,6 @@
 # format,
 #   runall clean
-#   runall README
-#   runall run_query
+#   runall setup
+#   runall run
 
 progname=$(basename $0)
Index: examples/runcheck
===================================================================
--- examples/runcheck	(revision 01ab2b100136fa0f4580b854230a6fdd3115ed31)
+++ examples/runcheck	(revision 9335cfa1f9ee260325c436b438f6063dfd4ec4e7)
@@ -3,31 +3,62 @@
 rm -rf allout.cn allout.sha
 
-echo '---one run-------'
-env ./runall run > allout.sha
-echo '---another run-------'
-env ABAC_CN=1 ./runall run > allout.cn
+echo 'running ABAC testing...'
+echo '  ---with sha'
+env ./runall run 1> allout.sha 2>/dev/null
+echo '  ---with cn'
+env ABAC_CN=1 ./runall run 1> allout.cn 2>/dev/null
 result=`diff allout.cn allout.save`
-echo '----------'
 
 if [ "$result" = "" ]; then
-   echo "...no changes..."
+   echo "   PASSED"
 else
-   echo "!!!got changes!!!"
+   echo "   ERROR:got changes!!!"
 fi
-echo '----------'
 echo "  "
 
-## special case, run a python in one of the directory
-echo "...special python test on access_rt2_typed..."
+## special case, run python script in one of the directory
+## to test the python/swig/libabac linkup
+echo "running special python testing in access_rt2_typed..."
+
 cd access_rt2_typed
-cmd1=`grep "cmd1:" query.py |sed "s/cmd1://g" `
-cmd2=`grep "cmd2:" query.py |sed "s/cmd2://g" `
+rm -rf python.cn
 
-echo '----------'
-echo $cmd1
-echo '----------'
-eval $cmd1
-echo '----------'
-echo $cmd2
-echo '----------'
-eval $cmd2
+g_cmd_sha=`grep "cmd1:" good_query.py |sed "s/cmd1://g" `
+g_cmd_cn=`grep "cmd2:" good_query.py |sed "s/cmd2://g" `
+b_cmd_sha=`grep "cmd1:" bad_query.py |sed "s/cmd1://g" `
+b_cmd_cn=`grep "cmd2:" bad_query.py |sed "s/cmd2://g" `
+
+echo '  ---good query with sh'
+eval $g_cmd_sha 2>/dev/null 1| grep 'YAP query succeed' >/dev/null
+if [ $? -eq 1 ]; then
+   echo  "   ERROR:python test failed for ($g_cmd_sha)"
+else
+   echo "   PASSED"
+fi
+
+echo '  ---good query with cn'
+eval $g_cmd_cn 2>/dev/null 1| tee python.cn | grep -c 'YAP query succeed' >/dev/null
+if [ $? -eq 0 ]; then
+   result=`diff python.cn python.save`
+   if [ "$result" = "" ]; then
+       echo "   PASSED"
+   else
+       echo "   ERROR:python test result differs!!!"
+   fi
+fi
+
+echo '  ---bad query with sh'
+eval $b_cmd_sha 2>/dev/null 1| grep 'YAP query failed' >/dev/null
+if [ $? -eq 1 ]; then
+   echo  "   ERROR:python test expected to fail but did not ($b_cmd_sha)"
+else
+   echo  "   PASSED"
+fi
+
+echo '  ---bad query with cn'
+eval $b_cmd_cn 2>/dev/null 1| grep 'YAP query failed' >/dev/null
+if [ $? -eq 1 ]; then
+   echo  "   ERROR:python test expected to fail but did not ($b_cmd_cn)"
+else
+   echo  "   PASSED"
+fi
