Index: examples/scaling_tests/haystack/fruit_python/base/ATTR.py
===================================================================
--- examples/scaling_tests/haystack/fruit_python/base/ATTR.py	(revision 373bf68f62f13aadf7c0872bcb63f63a67777f99)
+++ examples/scaling_tests/haystack/fruit_python/base/ATTR.py	(revision 373bf68f62f13aadf7c0872bcb63f63a67777f99)
@@ -0,0 +1,190 @@
+#!/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()
+
+# 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)
+
+# retrieve principals' keyid value from local credential files
+ralphsID=ABAC.ID("Ralphs_ID.pem");
+ralphsID.id_load_privkey_file("Ralphs_private.pem");
+ralphs=ralphsID.id_keyid()
+
+bobID=ABAC.ID("Bob_ID.pem");
+bobID.id_load_privkey_file("Bob_private.pem");
+bob=bobID.id_keyid()
+
+maryID=ABAC.ID("Mary_ID.pem");
+maryID.id_load_privkey_file("Mary_private.pem");
+mary=maryID.id_keyid()
+
+################################################
+# Credential 1, what kind of fruit Mary would eat. Anything not costing more
+#               than 2 dollars
+# [keyid:mary].oset:what2eat
+#      <- [keyid:ralphs].oset:fruitprice([float:?P:[..2.00]])
+head = ABAC.Oset(mary,"what2eat")
+
+# initialize a float range constraint
+cond=ABAC.Constraint("float")
+
+# add the upper max to the range, and only the max
+cond.constraint_add_float_max(2.00)
+
+# create the data term with the constraint
+param=ABAC.DataTerm("float", "P", cond)
+tail = ABAC.Oset(ralphs,"fruitprice")
+tail.oset_add_data_term(param)
+
+# compose the attribute policy
+attr=ABAC.Attribute(head, 1800)
+attr.attribute_add_tail(tail)
+
+#finalize the policy
+attr.attribute_bake()
+
+#write out the policy to a credential file
+attr.attribute_write_cert("mary_what2eat__ralphs_fruitprice_qP_attr.der")
+
+
+################################################
+# Credential 2,
+# [keyid:bob].oset:what2eat
+#      <- [keyid:ralphs].oset:fruitprice([float:?P:[1.00..5.00]])
+head = ABAC.Oset(bob,"what2eat")
+
+# initialze a float range constraint
+cond=ABAC.Constraint("float")
+
+# add the min and max value to the range
+cond.constraint_add_float_min(1.00)
+cond.constraint_add_float_max(5.00)
+param=ABAC.DataTerm("float", "P", cond)
+tail = ABAC.Oset(ralphs,"fruitprice")
+tail.oset_add_data_term(param)
+
+#create attribute policy
+attr=ABAC.Attribute(head, 1800)
+attr.attribute_add_tail(tail)
+
+#finalize the policy
+attr.attribute_bake()
+attr.attribute_write_cert("bob_what2eat__ralphs_fruitprice_qP_attr.der")
+
+#################################################
+# Credential 3
+# [keyid:ralphs].oset:fruitprice([float:1.50]) <- [string:'apple']
+param=ABAC.DataTerm("float", "1.50")
+head = ABAC.Oset(ralphs,"fruitprice")
+head.oset_add_data_term(param)
+param=ABAC.DataTerm("string", "'apple'")
+tail = ABAC.Oset(param)
+attr=ABAC.Attribute(head, 1800)
+attr.attribute_add_tail(tail)
+attr.attribute_bake()
+attr.attribute_write_cert("Ralphs_fruitprice__apple_attr.der")
+
+#################################################
+# Credential 4
+# [keyid:ralphs].oset:fruitprice([float:1.50]) <- [string:'kiwi']
+param=ABAC.DataTerm("float", "1.50")
+head = ABAC.Oset(ralphs,"fruitprice")
+head.oset_add_data_term(param)
+param=ABAC.DataTerm("string", "'kiwi'")
+tail = ABAC.Oset(param)
+attr=ABAC.Attribute(head, 1800)
+attr.attribute_add_tail(tail)
+attr.attribute_bake()
+attr.attribute_write_cert("Ralphs_fruitprice__kiwi_attr.der")
+
+#################################################
+# Credential 5
+# [keyid:ralphs].oset:fruitprice([float:2.50]) <- [string:'black berry']
+param=ABAC.DataTerm("float", "2.50")
+head = ABAC.Oset(ralphs,"fruitprice")
+head.oset_add_data_term(param)
+param=ABAC.DataTerm("string", "'black berry'")
+tail = ABAC.Oset(param)
+attr=ABAC.Attribute(head, 1800)
+attr.attribute_add_tail(tail)
+attr.attribute_bake()
+attr.attribute_write_cert("Ralphs_fruitprice__blackberry_attr.der")
+
+#################################################
+# Credential 6
+# [keyid:ralphs].oset:fruitprice([float:0.50]) <- [string:'navel orange']
+param=ABAC.DataTerm("float", "0.50")
+head = ABAC.Oset(ralphs,"fruitprice")
+head.oset_add_data_term(param)
+param=ABAC.DataTerm("string", "'navel orange'")
+tail = ABAC.Oset(param)
+attr=ABAC.Attribute(head, 1800)
+attr.attribute_add_tail(tail)
+attr.attribute_bake()
+attr.attribute_write_cert("Ralphs_fruitprice__navelorange_attr.der")
+
+
+########### NOISE #######################################
+# [keyid:Ralphs].oset:fruitprice([float:X.00])  <- [string:bananaY]
+i=1
+while i <= #VAL#:
+    p="%s.00"%i
+    n="'banana%s'"%i
+    nn="banana%s"%i
+    f="Ralphs_fruitprice__%s_attr.der"%nn
+    param=ABAC.DataTerm("float", p)
+    head = ABAC.Oset(ralphs,"fruitprice")
+    head.oset_add_data_term(param)
+    param=ABAC.DataTerm("string", n)
+    tail = ABAC.Oset(param)
+    attr=ABAC.Attribute(head, 1800)
+    attr.attribute_add_tail(tail)
+    attr.attribute_bake()
+    attr.attribute_write_cert(f)
+    i=i+1
+
+# [keyid:johnX].oset:what2eat
+#        <- [keyid:ralphs].oset:fruitprice([float:?P:[1.00..5.00]])
+i=1
+while i <= #VAL#:
+    j="john%s"%i
+    jid="%s_ID.pem"%j
+    jp="%s_private.pem"%j
+    f="%s_what2eat__ralphs_fruitprice_qP_attr.der"%j
+
+    jID=ABAC.ID(jid);
+    jID.id_load_privkey_file(jp);
+    john=jID.id_keyid()
+
+    head = ABAC.Oset(john,"what2eat")
+    cond=ABAC.Constraint("float")
+    cond.constraint_add_float_min(1.00)
+    cond.constraint_add_float_max(5.00)
+    param=ABAC.DataTerm("float", "P", cond)
+    tail = ABAC.Oset(ralphs,"fruitprice")
+    tail.oset_add_data_term(param)
+
+    attr=ABAC.Attribute(head, 1800)
+    attr.attribute_add_tail(tail)
+    attr.attribute_bake()
+    attr.attribute_write_cert(f)
+    i=i+1
+
+
Index: examples/scaling_tests/haystack/fruit_python/base/QUERY.py
===================================================================
--- examples/scaling_tests/haystack/fruit_python/base/QUERY.py	(revision 373bf68f62f13aadf7c0872bcb63f63a67777f99)
+++ examples/scaling_tests/haystack/fruit_python/base/QUERY.py	(revision 373bf68f62f13aadf7c0872bcb63f63a67777f99)
@@ -0,0 +1,123 @@
+#!/usr/bin/env python
+
+"""
+Run the queries described in README
+
+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)
+
+# retrieve principals' keyid value from local credential files
+ralphsID=ABAC.ID("Ralphs_ID.pem");
+ralphs=ralphsID.id_keyid()
+
+bobID=ABAC.ID("Bob_ID.pem");
+bob=bobID.id_keyid()
+
+maryID=ABAC.ID("Mary_ID.pem");
+mary=maryID.id_keyid()
+
+##########################################################################
+# dump the loaded principals/policies
+#
+
+fd=os.open("creds_dump",os.O_WRONLY|os.O_CREAT)
+out = ctxt.context_principals()
+for x in out[1]:
+    os.write(fd, x.string())
+    os.write(fd,"\n")
+out = ctxt.context_credentials()
+for c in out[1]:
+    string="%s <- %s\n" % (c.head_string(), c.tail_string())
+    os.write(fd,string) 
+os.close(fd)
+
+##########################################################################
+# Would Mary eat navel orange ?
+# oset = [keyid:mary].oset:what2eat 
+# p [string:'navel orange'] 
+oset = ABAC.Oset(mary,"what2eat")
+term=ABAC.DataTerm("string", "'navel orange'")
+p = ABAC.Oset(term)
+
+print "\n===good============ mary.what2eat <- navel orange"
+out = ctxt.query(oset, p)
+for c in out[1]:
+    print "%s <- %s" % (c.head_string(), c.tail_string())
+
+##########################################################################
+# Would Mary eat kiwi ?
+# oset = [keyid:mary].oset:what2eat 
+# p [string:'kiwi'] 
+oset = ABAC.Oset(mary,"what2eat")
+term=ABAC.DataTerm("string", "'kiwi'")
+p = ABAC.Oset(term)
+
+print "\n===good============ mary.what2eat <- kiwi"
+out = ctxt.query(oset, p)
+for c in out[1]:
+    print "%s <- %s" % (c.head_string(), c.tail_string())
+
+##########################################################################
+# Would Bob eat navel orange ?
+# oset = [keyid:bob].oset:what2eat 
+# p [string:'navel orange'] 
+oset = ABAC.Oset(bob,"what2eat")
+term=ABAC.DataTerm("string", "'navel orange'")
+p = ABAC.Oset(term)
+
+print "\n===bad============ bob.what2eat <- navel orange"
+out = ctxt.query(oset, p)
+for c in out[1]:
+    print "%s <- %s" % (c.head_string(), c.tail_string())
+
+##########################################################################
+# Is Apple 1.50 at Ralphs ?
+# oset = [keyid:$ralphs].oset:fruitprice([float:1.50]) 
+# p = [string:'apple'] 
+param=ABAC.DataTerm("float", "1.50")
+oset = ABAC.Oset(ralphs,"fruitprice")
+oset.oset_add_data_term(param)
+term=ABAC.DataTerm("string", "'apple'")
+p = ABAC.Oset(term)
+
+print "\n===good============ ralphs.fruitprice(1.50) <- apple"
+out = ctxt.query(oset, p)
+for c in out[1]:
+    print "%s <- %s" % (c.head_string(), c.tail_string())
+
+##########################################################################
+# Is green apple 1.50 at Ralphs ?
+# oset = [keyid:$ralphs].oset:fruitprice([float:1.50]) 
+# p = [string:'green apple'] 
+param=ABAC.DataTerm("float", "1.50")
+oset = ABAC.Oset(ralphs,"fruitprice")
+oset.oset_add_data_term(param)
+term=ABAC.DataTerm("string", "'green apple'")
+p = ABAC.Oset(term)
+
+print "\n===bad============ ralphs.fruitprice(1.50) <- green apple"
+out = ctxt.query(oset, p)
+for c in out[1]:
+    print "%s <- %s" % (c.head_string(), c.tail_string())
+
+##########################################################################
+# dump the yap dB
+#
+#ctxt.dump_yap_db()
+
Index: examples/scaling_tests/haystack/fruit_python/base/README
===================================================================
--- examples/scaling_tests/haystack/fruit_python/base/README	(revision 373bf68f62f13aadf7c0872bcb63f63a67777f99)
+++ examples/scaling_tests/haystack/fruit_python/base/README	(revision 373bf68f62f13aadf7c0872bcb63f63a67777f99)
@@ -0,0 +1,35 @@
+#!/bin/sh
+#
+#  This demonstrates scalability of libabac. The fruit_rt2 test from 
+#  python_tests is use as the base. 
+#       #VAL# simple attribute credentials are added, 
+#       #VAL# complex attribute credentials along 
+#             with #VAL# different principal ids are added.
+#  The same queries used in fruit_rt2 are run against this setup and 
+#  should  yield the same result
+
+# fruits_rt2
+
+# Credential 1
+# [keyid:mary].oset:what2eat 
+#      <- [keyid:ralphs].oset:fruitprice([float:?P:[..2.00]])
+
+# Credential 2
+# [keyid:bob].oset:what2eat 
+#      <- [keyid:ralphs].oset:fruitprice([float:?P:[1.00..5.00]])
+
+# Credential 3
+# [keyid:ralphs].oset:fruitprice([float:1.50]) <- [string:'apple']
+
+# Credential 4
+# [keyid:ralphs].oset:fruitprice([float:1.50]) <- [string:'kiwi']
+
+# Credential 5
+# [keyid:ralphs].oset:fruitprice([float:2.50]) <- [string:'black rasberry']
+
+# Credential 6
+# [keyid:ralphs].oset:fruitprice([float:0.50]) <- [string:'navel orange']
+
+
+
+
Index: examples/scaling_tests/haystack/fruit_python/base/RESULT
===================================================================
--- examples/scaling_tests/haystack/fruit_python/base/RESULT	(revision 373bf68f62f13aadf7c0872bcb63f63a67777f99)
+++ examples/scaling_tests/haystack/fruit_python/base/RESULT	(revision 373bf68f62f13aadf7c0872bcb63f63a67777f99)
@@ -0,0 +1,20 @@
+
+===good============ mary.what2eat <- navel orange
+YAP query succeed
+pMary.what2eat <- pRalphs.fruitprice(P:[..2.000000])
+pRalphs.fruitprice(0.50) <- 'navel orange'
+
+===good============ mary.what2eat <- kiwi
+YAP query succeed
+pMary.what2eat <- pRalphs.fruitprice(P:[..2.000000])
+pRalphs.fruitprice(1.50) <- 'kiwi'
+
+===bad============ bob.what2eat <- navel orange
+YAP query failed
+
+===good============ ralphs.fruitprice(1.50) <- apple
+YAP query succeed
+pRalphs.fruitprice(1.50) <- 'apple'
+
+===bad============ ralphs.fruitprice(1.50) <- green apple
+YAP query failed
Index: examples/scaling_tests/haystack/fruit_python/base/SETUP.py
===================================================================
--- examples/scaling_tests/haystack/fruit_python/base/SETUP.py	(revision 373bf68f62f13aadf7c0872bcb63f63a67777f99)
+++ examples/scaling_tests/haystack/fruit_python/base/SETUP.py	(revision 373bf68f62f13aadf7c0872bcb63f63a67777f99)
@@ -0,0 +1,37 @@
+#!/usr/bin/env python
+
+"""
+See README for the semantics.  This creates principals
+used by the example.
+"""
+import os
+import ABAC
+
+ctxt = ABAC.Context()
+
+ralphsID=ABAC.ID("Ralphs", 0)
+ralphsID.id_write_cert("Ralphs_ID.pem")
+ralphsID.id_write_privkey("Ralphs_private.pem")
+
+bobID=ABAC.ID("Bob", 0)
+bobID.id_write_cert("Bob_ID.pem")
+bobID.id_write_privkey("Bob_private.pem")
+
+maryID=ABAC.ID("Mary", 0)
+maryID.id_write_cert("Mary_ID.pem")
+maryID.id_write_privkey("Mary_private.pem")
+
+######## NOISE ##################################
+
+i=1
+while i <= #VAL#:
+     n="john%s"%i 
+     nid="%s_ID.pem"%n
+     np="%s_private.pem"%n
+     aD=ABAC.ID(n, 0)
+     aD.id_write_cert(nid)
+     aD.id_write_privkey(np)
+     i = i+1
+
+
+
Index: examples/scaling_tests/haystack/fruit_python/get_time
===================================================================
--- examples/scaling_tests/haystack/fruit_python/get_time	(revision 373bf68f62f13aadf7c0872bcb63f63a67777f99)
+++ examples/scaling_tests/haystack/fruit_python/get_time	(revision 373bf68f62f13aadf7c0872bcb63f63a67777f99)
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+grep user fruit_*/fruit.time
Index: examples/scaling_tests/haystack/fruit_python/run_clean
===================================================================
--- examples/scaling_tests/haystack/fruit_python/run_clean	(revision 373bf68f62f13aadf7c0872bcb63f63a67777f99)
+++ examples/scaling_tests/haystack/fruit_python/run_clean	(revision 373bf68f62f13aadf7c0872bcb63f63a67777f99)
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+rm -rf fruit_*
Index: examples/scaling_tests/haystack/fruit_python/run_one
===================================================================
--- examples/scaling_tests/haystack/fruit_python/run_one	(revision 373bf68f62f13aadf7c0872bcb63f63a67777f99)
+++ examples/scaling_tests/haystack/fruit_python/run_one	(revision 373bf68f62f13aadf7c0872bcb63f63a67777f99)
@@ -0,0 +1,25 @@
+#!/bin/sh 
+
+
+noise=$1
+
+rm -rf fruit_$noise
+mkdir fruit_$noise
+sed "s/#VAL#/$noise/" base/SETUP.py > fruit_$noise/setup.py
+cp base/RESULT fruit_$noise/fruit.save
+cp base/QUERY.py fruit_$noise/query.py
+sed "s/#VAL#/$noise/" base/ATTR.py > fruit_$noise/attr.py
+
+cd fruit_$noise
+chmod +x setup.py attr.py query.py
+./setup.py 1>/dev/null 2>& 1
+env keystore=`pwd` ./attr.py 1>/dev/null 2>& 1
+time env keystore=`pwd` ABAC_CN=1 ./query.py 1>fruit.tmp 2> fruit.time
+result=`diff fruit.tmp fruit.save 2>/dev/null`
+if [ "$result" = "" ]; then
+   echo "   PASSED"
+else   
+   echo "   ERROR"
+fi
+
+
Index: examples/scaling_tests/haystack/fruit_python/run_test
===================================================================
--- examples/scaling_tests/haystack/fruit_python/run_test	(revision 373bf68f62f13aadf7c0872bcb63f63a67777f99)
+++ examples/scaling_tests/haystack/fruit_python/run_test	(revision 373bf68f62f13aadf7c0872bcb63f63a67777f99)
@@ -0,0 +1,55 @@
+#!/bin/sh 
+
+run_clean
+
+echo '---running haystack fruit_python 0 scaling'
+run_one 0  1> log 2>/dev/null
+result=`grep PASSED log 2>/dev/null`
+if [ "$result" = "" ]; then
+   echo "   ERROR"
+else   
+   echo "   PASSED"
+fi
+rm -rf log
+
+
+echo '---running haystack fruit_python 10 scaling'
+run_one 10  1> log 2>/dev/null
+result=`grep PASSED log 2>/dev/null`
+if [ "$result" = "" ]; then
+   echo "   ERROR"
+else   
+   echo "   PASSED"
+fi
+rm -rf log
+
+echo '---running haystack fruit_python 20 scaling'
+run_one 20  1> log 2>/dev/null
+result=`grep PASSED log 2>/dev/null`
+if [ "$result" = "" ]; then
+   echo "   ERROR"
+else   
+   echo "   PASSED"
+fi
+rm -rf log
+
+echo '---running haystack fruit_python 30 scaling'
+run_one 30  1> log 2>/dev/null
+result=`grep PASSED log 2>/dev/null`
+if [ "$result" = "" ]; then
+   echo "   ERROR"
+else   
+   echo "   PASSED"
+fi
+rm -rf log
+
+echo '---running haystack fruit_python 200 scaling'
+run_one 200  1> log 2>/dev/null
+result=`grep PASSED log 2>/dev/null`
+if [ "$result" = "" ]; then
+   echo "   ERROR"
+else   
+   echo "   PASSED"
+fi
+rm -rf log
+
