Index: examples/access_tests/creddy_prover/s6_query.py
===================================================================
--- examples/access_tests/creddy_prover/s6_query.py	(revision 2e9455f11fea0205b8b4b1306b5d0804cda72e10)
+++ examples/access_tests/creddy_prover/s6_query.py	(revision 2e9455f11fea0205b8b4b1306b5d0804cda72e10)
@@ -0,0 +1,199 @@
+#!/usr/bin/env python
+
+"""
+  s6_query.py
+using python api
+
+"""
+
+print("=====================s6_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, using current directory...")
+    ctxt.load_directory(".")
+
+##########################################################################
+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
+
+# dump the loaded principals/policies
+def dump_all(CTXT,msg) :
+    out = CTXT.context_principals()
+    print "\n...%s principal set..." % msg
+    for x in out[1]:
+        print "#PP# %s " % x.string()
+    out = CTXT.context_credentials()
+    print "\n...%s policy attribute set..." %msg
+    for c in out[1]:
+        print "#CC# %s <- %s" % (c.head_string(), c.tail_string())
+
+##########################################################################
+# retrieve principals' keyid value from local credential files
+gID=ABAC.ID("G_ID.pem");
+g=gID.id_keyid()
+
+saID=ABAC.ID("SA_ID.pem");
+sa=saID.id_keyid()
+
+paID=ABAC.ID("PA_ID.pem");
+pa=paID.id_keyid()
+
+drdID=ABAC.ID("Drd_ID.pem");
+drd=drdID.id_keyid()
+
+frankID=ABAC.ID("Frank_ID.pem");
+frank=frankID.id_keyid()
+
+danID=ABAC.ID("Dan_ID.pem");
+dan=danID.id_keyid()
+
+aliceID=ABAC.ID("Alice_ID.pem");
+alice=aliceID.id_keyid()
+
+lisaID=ABAC.ID("Lisa_ID.pem");
+lisa=lisaID.id_keyid()
+
+##########################################################################
+dump_all(ctxt,"initial")
+#ctxt.set_no_partial_proof()
+
+##########################################################################
+# [keyid:SA].role:controlsQ(string:'sliceA'],[string:'info']) <-?- [keyid:Drd] 
+role = ABAC.Role(sa,"controlsQ")
+param1=ABAC.DataTerm("string", "'sliceA'")
+param2=ABAC.DataTerm("string", "'info'")
+role.role_add_data_term(param1)
+role.role_add_data_term(param2)
+p = ABAC.Role(drd)
+print "\n===good============ SA.controlsQ('sliceA','info') <-?- Drd"
+out = ctxt.query(role, p)
+for c in out[1]:
+    print "%s <- %s" % (c.head_string(), c.tail_string())
+#get_next(ctxt)
+
+##########################################################################
+# [keyid:SA].role:createSlice(string:'proj1']) <-?- [keyid:Drd] 
+role = ABAC.Role(sa,"createSlice")
+param=ABAC.DataTerm("string", "'proj1'")
+role.role_add_data_term(param)
+p = ABAC.Role(drd)
+print "\n===good============ SA.createSlice('proj1') <-?- Drd"
+out = ctxt.query(role, p)
+for c in out[1]:
+    print "%s <- %s" % (c.head_string(), c.tail_string())
+
+##########################################################################
+oset = ABAC.Oset(sa,"Standard")
+term=ABAC.DataTerm("string", "'sliceA'")
+p = ABAC.Oset(term)
+print "\n===good============ SA.Stanard <-?- 'sliceA'"
+out = ctxt.query(oset, p)
+for c in out[1]:
+    print "%s <- %s" % (c.head_string(), c.tail_string())
+
+##########################################################################
+oset = ABAC.Oset(sa,"inProject")
+param=ABAC.DataTerm("string", "'proj1'")
+oset.oset_add_data_term(param)
+term=ABAC.DataTerm("string", "'sliceA'")
+p = ABAC.Oset(term)
+print "\n===good============ SA.inProject('proj1') <-?- 'sliceA'"
+out = ctxt.query(oset, p)
+for c in out[1]:
+    print "%s <- %s" % (c.head_string(), c.tail_string())
+
+##########################################################################
+# [keyid:SA].oset:inStdProject("proj1") <- "sliceA"
+oset = ABAC.Oset(sa,"inStdProject")
+param=ABAC.DataTerm("string", "'proj1'")
+oset.oset_add_data_term(param)
+term=ABAC.DataTerm("string", "'sliceA'")
+p = ABAC.Oset(term)
+print "\n===good============ SA.inStdProject('proj1') <-?- 'sliceA'"
+out = ctxt.query(oset, p)
+for c in out[1]:
+    print "%s <- %s" % (c.head_string(), c.tail_string())
+
+##########################################################################
+# [keyid:SA].role:createSlice(string:'proj1']) <-?- [keyid:lisa] 
+role = ABAC.Role(sa,"createSlice")
+param=ABAC.DataTerm("string", "'proj1'")
+role.role_add_data_term(param)
+p = ABAC.Role(lisa)
+print "\n===good============ SA.createSlice('proj1') <-?- lisa"
+out = ctxt.query(role, p)
+for c in out[1]:
+    print "%s <- %s" % (c.head_string(), c.tail_string())
+get_next(ctxt)
+
+##########################################################################
+# [keyid:SA].role:createSlice(string:'proj1']) <-?- [keyid:Dan] 
+role = ABAC.Role(sa,"createSlice")
+param=ABAC.DataTerm("string", "'proj1'")
+role.role_add_data_term(param)
+p = ABAC.Role(dan)
+print "\n===good============ SA.createSlice('proj1') <-?- Dan"
+out = ctxt.query(role, p)
+for c in out[1]:
+    print "%s <- %s" % (c.head_string(), c.tail_string())
+get_next(ctxt)
+
+##########################################################################
+# [keyid:SA].role:createSlice(string:'proj1']) <-?- [keyid:Frank] 
+role = ABAC.Role(sa,"createSlice")
+param=ABAC.DataTerm("string", "'proj1'")
+role.role_add_data_term(param)
+p = ABAC.Role(frank)
+print "\n===bad============ SA.createSlice('proj1') <-?- Frank"
+out = ctxt.query(role, p)
+for c in out[1]:
+    print "%s <- %s" % (c.head_string(), c.tail_string())
+
+##########################################################################
+#(SA.projectAuthority).memberQ(?P, "instantiate")
+# [keyid:PA].role:memberQ(string:'proj1'],[string:'instantiate']) <-?- [keyid:Dan] 
+role = ABAC.Role(pa,"memberQ")
+param1=ABAC.DataTerm("string", "'proj1'")
+param2=ABAC.DataTerm("string", "'instantiate'")
+role.role_add_data_term(param1)
+role.role_add_data_term(param2)
+p = ABAC.Role(dan)
+print "\n===good============ PA.memberQ('proj1','instantiate') <-?- Dan"
+out = ctxt.query(role, p)
+for c in out[1]:
+    print "%s <- %s" % (c.head_string(), c.tail_string())
+get_next(ctxt)
+
+##########################################################################
+# speaksFor((SA.projectAuthority).memberQ(?P, "instantiate")
+# attr="[keyid:$sa].role:speaksFor([keyid:$dan]) <- [keyid:$frank]"
+role = ABAC.Role(sa,"speaksFor")
+param=ABAC.DataTerm(danID)
+role.role_add_data_term(param)
+p = ABAC.Role(frank)
+print "\n===bad============ SA.speaksFor(Dan) <-?- Frank"
+out = ctxt.query(role, p)
+for c in out[1]:
+    print "%s <- %s" % (c.head_string(), c.tail_string())
+get_next(ctxt)
+
+
+print("\n\n")
