Index: examples/example_scripts/python/IceCream_ID.pem
===================================================================
--- examples/example_scripts/python/IceCream_ID.pem	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
+++ examples/example_scripts/python/IceCream_ID.pem	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
@@ -0,0 +1,19 @@
+-----BEGIN CERTIFICATE-----
+MIIDCzCCAfOgAwIBAgIIYWmVNsrLroowDQYJKoZIhvcNAQEFBQAwEzERMA8GA1UE
+AxMISWNlQ3JlYW0wHhcNMTIwODA0MDM0NjA4WhcNMTUwNzIwMDM0NjA4WjATMREw
+DwYDVQQDEwhJY2VDcmVhbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
+AK6zVvhBJZ01kyEw/Z8XC49VDTjrsuKzlC5zfD4JV1IHktzOwoc05oxPMYW+SshL
+37CRc+MBa/giPYxy08BWlnF/qsdqPwQPNZpORdkwMtQkGBIVkqWN+LkssjHbzJTj
+zGG678zLRslGa7W082L2eKr9EwV/yiooZFfKNcKehLtDJRQUrPitwRvcmW0DUAoz
+im+4F3eP5tEISVvDgUmneiiNoldD1bCqWpAO9y2bpgBCOf3x/rfB6TDWcHFG+LIB
+d8oXxcCSesOFqz9Twv3RkNa06sctet8bXY/mbl6uUvx1H7uyLsHUqcnylQKhisIU
+jfS6DIBGE4kg/wdFcexCrskCAwEAAaNjMGEwDwYDVR0TAQH/BAUwAwEB/zAOBgNV
+HQ8BAf8EBAMCAQYwHQYDVR0OBBYEFOp5Vugz4M66LXF/ZF7S414MJ/QKMB8GA1Ud
+IwQYMBaAFOp5Vugz4M66LXF/ZF7S414MJ/QKMA0GCSqGSIb3DQEBBQUAA4IBAQCo
+iXog4DmsZiJpeHYKGTsvAXL1cXmPQSoLvX/S7VOYt16/YqElm2pGH+VVSl1b5mdJ
+FlHEnqI/DmPPqUTy5dSOyTvEqIQamQUlrzFdY7vJRjNQ9854DufofEUXVDkd3hnj
+Qng4/2cKsdsDjgNP4i9+Pmo/vVqEuZa4S4W3I+tW/jEYCEnJUZ49XSLPWT1xrdPm
+FOAiNw4Ih/FU0mOQxSUIX8AQJgqIe8CHsr1FOCMAla3mDFzGY/nZIAhfVBeHwLk8
+A0iMwhJoK6/ayTtHXsB9nv2rYezKb1TepG/7rafOkAxug7atk+Wt+v+V09mS+aIu
+Tlhv0qOxpoxm8b3EzLQK
+-----END CERTIFICATE-----
Index: examples/example_scripts/python/IceCream_private.pem
===================================================================
--- examples/example_scripts/python/IceCream_private.pem	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
+++ examples/example_scripts/python/IceCream_private.pem	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
@@ -0,0 +1,27 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIEpQIBAAKCAQEArrNW+EElnTWTITD9nxcLj1UNOOuy4rOULnN8PglXUgeS3M7C
+hzTmjE8xhb5KyEvfsJFz4wFr+CI9jHLTwFaWcX+qx2o/BA81mk5F2TAy1CQYEhWS
+pY34uSyyMdvMlOPMYbrvzMtGyUZrtbTzYvZ4qv0TBX/KKihkV8o1wp6Eu0MlFBSs
++K3BG9yZbQNQCjOKb7gXd4/m0QhJW8OBSad6KI2iV0PVsKpakA73LZumAEI5/fH+
+t8HpMNZwcUb4sgF3yhfFwJJ6w4WrP1PC/dGQ1rTqxy163xtdj+ZuXq5S/HUfu7Iu
+wdSpyfKVAqGKwhSN9LoMgEYTiSD/B0Vx7EKuyQIDAQABAoIBAQCONsPnl/Dsxz4c
+WOs9ZN8uMQhwe77FuXY5Uh2jyqrgxfWR9mZ49mFvetBPlZb+8nUIIX/7HZ8tAYKl
+IJysCFCz2D/H0f+2aEM0d994bDoUY8WMgy87whTleTMeT1V9Juur6ydmyVu4YbEw
+3Dr9JrMYTqf7ZAnIw9TbemrFIZHfdfIdYrjiGEqQirGaDYqjSH/dBCdqHqi5Eree
+WdH/0F+NbYH2opyf9vyPrBVUUgGegl/Pn22EW7KJXIt8Lx+s+V1CI4I70I7svHQD
+8Hj1l3Ch0775Bc5A52pImA6Gtnw+dH5/iVIsPlfkWt8QVb3KwhNjx+ugIv2lOzLP
+gVcvnwoBAoGBAOQnk6THZNXaARlLQru9ePy7K9p33Djb7MgVzgnyUPL1jMWFrRDY
+AXVbFUlmwRZNd95ZMLwiDm2HiEwy6kX5xFP13O1ER9TEFge4koCc46mEHWMBA1nI
+RmkCu1A+updxH5VkmKMTN3Z+/zU9U8OzseXnH6qRpAbLXN4qfJrBoMNpAoGBAMQF
+p1xzRKedFJobet0Flx2sFUp9q/gWAjarsJPE7KNKZVE6ydt5KW9fLgkF6zjVXlUl
+e6+blAeF4KU0YNg+VS3og6WOtsshyWfP3M7XDBqy6kqDQphxlSr8T0YXtocmVO5j
+idKFBxy6FI3A9kzf1y66gYUCSOKUoRvUijxmkwRhAoGBAKVT0Hc9TeJxQQ6VLNxi
+ZkOtVg/PfzNsml46/rzSbLpCGSogvdJQ1G23/OrdnNmOdWgX9Wq+uvm/lpKw6nae
+kRfON7NvISYamWQq6W5tQcPaynitiUIMEImTwyxY6FlJTfuxk7HIAQ7K5CAuOn67
+vhO8sYOmWdfakYcj/nseCGLRAoGBAIA+Iqw9TWFLRzs7Vzpaee8Tsio15dg8rd4O
+nUtPvnFmLrrh90X7ErymTHviv21DSp/yEeVlp4b0c3AhwGo4/Yk3YUljAPwMcrPU
+LeW0k1q0SsvM7DjHtouU3lhBE02AKnh77qMoHOsSYngLEhhhKWqM4keeowh5rJ2E
+g5vYj76BAoGAcIYNCEYzwmJrOrx6AlaA1JAfJm8ECSsEV0KcGbf9I+35pu7XOg7z
+nsOwzg4FmBk6I859uM2xHYbNN1wHD9G+U2By14D3gW1cRgDYGnRgYmSdxrOAZSdn
+rgb3cSk4TjWZZUFzIvtYfezP+nOy0e5G0q+F/LPWCEtxHnit9QDAR1U=
+-----END RSA PRIVATE KEY-----
Index: examples/example_scripts/python/Makefile
===================================================================
--- examples/example_scripts/python/Makefile	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
+++ examples/example_scripts/python/Makefile	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
@@ -0,0 +1,33 @@
+clean:
+	rm -f *.pem *.der 
+
+realclean:
+	rm -f *.pem *.der *.log pfile
+
+run_attr: 
+	make clean
+	rm -rf attr.log
+	creddy --generate --cn IceCream
+	creddy --generate --cn Chocolate
+	./abac_attr.py IceCream_ID.pem IceCream_private.pem IceCream_attr.der Chocolate_ID.pem 1>attr.log 2>&1
+
+run_e_attr: 
+	make clean
+	rm -rf e_attr.log pfile
+	echo "dumdum" > pfile
+	openssl genrsa -des3 -out Soda_private.pem -passout file:pfile
+	creddy --generate --cn Soda --key Soda_private.pem --p=pfile
+	creddy --generate --cn Cream
+	./abac_e_attr.py Soda_ID.pem Soda_private.pem Soda_attr.der pfile Cream_ID.pem 1>e_attr.log 2>&1
+
+run_id: 
+	make clean
+	rm -rf id.log
+	creddy --generate --cn IceCream
+	./abac_keyid.py IceCream_ID.pem 1>id.log 2>&1
+                             
+run_id2: 
+	make clean
+	rm -rf id2.log
+	creddy --generate --cn IceCream
+	./abac_keyid.py IceCream_private.pem 1>id2.log 2>&1
Index: examples/example_scripts/python/abac_attr.py
===================================================================
--- examples/example_scripts/python/abac_attr.py	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
+++ examples/example_scripts/python/abac_attr.py	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
@@ -0,0 +1,105 @@
+#!/usr/bin/env python
+
+/**
+   abac_attr.py
+
+   To demonstrate how to use ABAC's api in C
+
+   call:   attr_abac IceCream_ID.pem IceCream_private.pem IceCream_attr.der Chocolate_ID.pem
+
+   pre-conditions: generate IceCream_ID.pem and IceCream_private.pem with
+           creddy --generate --cn IceCream
+                   generate Chocolate_ID.pem and Chocolate_private.pem with
+           creddy --generate --cn Chocolate
+
+   This program will generate an attribute rule, write it out to an external
+           file and also load it into the context (prolog db)
+           [keyid:IceCream].delicious <- [Keyid:Chocolate]
+
+   Then, a query is made against the context to see if it is populated correctly.
+
+   Note: Chocolate's principal is loaded without it private key. It does not
+         need to because it is not being used to generate attribute credential
+
+**/
+
+
+from sys import argv, exit
+from ABAC import Context
+from ABAC import ID, Attribute, Role
+
+debug=0
+
+## initial context
+ctxt = Context()
+
+if len(argv) != 5:
+    print "Usage: abac_attr.py <cert.pem> <key.pem> <attr.der> <pcert.pem>"
+    exit(1)
+
+# load the ID and its key
+id = None
+try:
+    id = ID(argv[1])
+    id.id_load_privkey_file(argv[2])
+    chocolate_id = ID(argv[4])
+except Exception, e:
+    print "Problem loading ID cert: %s" % e
+    exit(1)
+
+if debug :
+    print "before the load"
+    id.print_key_chunk()
+
+# load the id into the context
+ctxt.load_id_chunks(id.id_cert_chunk(), id.id_privkey_chunk())
+# another way to load the id into the context
+#ctxt.load_id(id)
+ctxt.load_id(chocolate_id)
+
+if debug :
+    print "after the load"
+    print "old,"
+    id.print_key_chunk()
+
+nid=ctxt.lookup_principal(id.id_keyid())
+if debug :
+    print "new,"
+    nid.print_key_chunk()
+
+out = ctxt.context_principals()
+print "\n...final principal set..."
+for x in out[1]:
+    print "%s " % x.string()
+
+
+# create an attribute cert
+# iceCream.delicous <- chocolate
+head= Role(id.id_keyid(),"delicious")
+tail= Role(chocolate_id.id_keyid())
+
+attr = Attribute(head, 1800)
+attr.attribute_add_tail(tail)
+attr.attribute_bake()
+
+# load attribute cert into the context
+ctxt.load_attribute_chunk(attr.cert_chunk())
+
+# another way to load the attribute cert into the context,
+# ctxt.load_attribute(attr)
+
+# yet another way to load the attribute cert into the context,
+attr.attribute_write_cert(argv[3])
+# ctxt.load_attribute_file(argv[3])
+
+# what is in prolog db
+# ctxt.dump_yap_db()
+
+# run a proof
+role = Role(id.id_keyid(),"delicious")
+p=Role(chocolate_id.id_keyid())
+
+out = ctxt.query(role, p)
+for c in out[1]:
+    print "%s <- %s" % (c.head_string(), c.tail_string())
+
Index: examples/example_scripts/python/abac_e_attr.py
===================================================================
--- examples/example_scripts/python/abac_e_attr.py	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
+++ examples/example_scripts/python/abac_e_attr.py	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
@@ -0,0 +1,108 @@
+#!/usr/bin/env python
+
+/**
+   abac_e_attr.py
+
+   To demonstrate how to use ABAC's api in C with principal credential that uses
+   encrypted private key
+
+   call:   attr_e_abac Soda_ID.pem Soda_private.pem Soda_attr.der pfile Cream_ID.pem
+
+   pre-conditions: generate Soda_ID.pem and Soda_private.pem with
+           creddy --generate --cn Soda
+                   generate Chocolate_ID.pem and Chocolate_private.pem with
+           creddy --generate --cn Cream
+                   generate passphrase file
+                   generate a private key using openssl
+
+   This program will generate an attribute rule, write it out to an external
+           file and also load it into the context (prolog db)
+           [keyid:Soda].delicious <- [Keyid:Chocolate]
+
+   Then, a query is made against the context to see if it is populated correctly.
+
+   Note: Cream's principal is loaded without it private key. It does not
+         need to because it is not being used to generate attribute credential
+
+**/
+
+
+
+
+from sys import argv, exit
+from ABAC import Context
+from ABAC import ID, Attribute, Role
+
+debug=0
+
+## initial context
+ctxt = Context()
+
+if len(argv) != 6:
+    print "Usage: abac_attr.py <cert.pem> <key.pem> <attr.der> <pfile> <c_cert.pem>"
+    exit(1)
+
+# load the ID and its key
+id = None
+try:
+    id = ID(argv[1])
+    id.id_load_encrypted_privkey_file(argv[2], argv[4])
+    cream_id = ID(argv[5])
+except Exception, e:
+    print "Problem loading ID cert: %s" % e
+    exit(1)
+
+if debug :
+    print "before the load"
+    id.print_key_chunk()
+
+# load the id into the context
+ctxt.load_id_encrypted_chunks(id.id_cert_chunk(), id.id_privkey_chunk(), argv[4])
+# another way to load the id into the context
+ctxt.load_id(cream_id)
+
+if debug :
+    print "after the load"
+    print "old,"
+    id.print_key_chunk()
+
+nid=ctxt.lookup_principal(id.id_keyid())
+if debug :
+    print "new,"
+    nid.print_key_chunk()
+
+out = ctxt.context_principals()
+print "\n...final principal set..."
+for x in out[1]:
+    print "%s " % x.string()
+
+
+# create an attribute cert
+head= Role(id.id_keyid(),"delicious")
+tail= Role(cream_id.id_keyid())
+
+attr = Attribute(head, 1800)
+attr.attribute_add_tail(tail)
+attr.attribute_bake()
+
+# load attribute cert into the context
+ctxt.load_attribute_chunk(attr.cert_chunk())
+
+# another way to load the attribute cert into the context,
+# ctxt.load_attribute(attr)
+
+# yet another way to load the attribute cert into the context,
+attr.attribute_write_cert(argv[3])
+# ctxt.load_attribute_file(argv[3])
+
+# what is in prolog db
+# ctxt.dump_yap_db()
+
+# run a proof
+role = Role(id.id_keyid(),"delicious")
+p=Role(cream_id.id_keyid())
+
+out = ctxt.query(role, p)
+for c in out[1]:
+    print "%s <- %s" % (c.head_string(), c.tail_string())
+
Index: examples/example_scripts/python/abac_keyid.py
===================================================================
--- examples/example_scripts/python/abac_keyid.py	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
+++ examples/example_scripts/python/abac_keyid.py	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
@@ -0,0 +1,33 @@
+#!/usr/bin/env python
+
+/**
+
+  abac_keyid.py
+
+   To demonstrate how to use ABAC's api in C to access keyid of a 
+principal credential
+
+   pre-condition: generate IceCream_ID.pem and IceCream_private.pem with
+           creddy --generate --cn IceCream
+
+   keyid of the loaded principal credential is printed
+
+**/
+
+
+from sys import argv, exit
+from ABAC import ID
+
+if len(argv) < 2:
+    print "Usage: abac_keyid.py <cert.pem>"
+    exit(1)
+
+id = None
+try:
+    print argv[1]
+    id = ID(argv[1])
+except Exception, e:
+    print "Problem loading cert: %s" % e
+    exit(1)
+
+print id.id_keyid()
Index: examples/example_scripts/python/attr.log
===================================================================
--- examples/example_scripts/python/attr.log	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
+++ examples/example_scripts/python/attr.log	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
@@ -0,0 +1,4 @@
+  File "./abac_attr.py", line 3
+    /**
+    ^
+SyntaxError: invalid syntax
Index: examples/example_scripts/python/e_attr.log
===================================================================
--- examples/example_scripts/python/e_attr.log	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
+++ examples/example_scripts/python/e_attr.log	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
@@ -0,0 +1,4 @@
+  File "./abac_e_attr.py", line 3
+    /**
+    ^
+SyntaxError: invalid syntax
Index: examples/example_scripts/python/id.log
===================================================================
--- examples/example_scripts/python/id.log	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
+++ examples/example_scripts/python/id.log	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
@@ -0,0 +1,4 @@
+  File "./abac_keyid.py", line 3
+    /**
+    ^
+SyntaxError: invalid syntax
Index: examples/example_scripts/python/id2.log
===================================================================
--- examples/example_scripts/python/id2.log	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
+++ examples/example_scripts/python/id2.log	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
@@ -0,0 +1,4 @@
+  File "./abac_keyid.py", line 3
+    /**
+    ^
+SyntaxError: invalid syntax
Index: examples/example_scripts/python/pfile
===================================================================
--- examples/example_scripts/python/pfile	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
+++ examples/example_scripts/python/pfile	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
@@ -0,0 +1,1 @@
+dumdum
Index: examples/example_scripts/python/run_test
===================================================================
--- examples/example_scripts/python/run_test	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
+++ examples/example_scripts/python/run_test	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
@@ -0,0 +1,37 @@
+#!/bin/sh 
+
+echo '---running (python) attr script'
+make run_attr 1>/dev/null 2>& 1
+result=`grep succeed attr.log 2>/dev/null`
+if [ "$result" = "" ]; then
+   echo "   ERROR"
+else   
+   echo "   PASSED"
+fi
+
+echo '---running (python) encrypted key attr script'
+make run_e_attr 1>/dev/null 2>& 1
+result=`grep succeed e_attr.log 2>/dev/null`
+if [ "$result" = "" ]; then
+   echo "   ERROR"
+else   
+   echo "   PASSED"
+fi
+
+echo '---running (python) id script'
+make run_id 1>/dev/null 2>& 1
+result=`grep IceCream_ID.pem id.log 2>/dev/null`
+if [ "$result" = "" ]; then
+   echo "   ERROR"
+else   
+   echo "   PASSED"
+fi
+
+echo '---running (python) id script, expect failure'
+make run_id2 1>/dev/null 2>& 1
+result=`grep "Id creation from filename failed" id2.log 2>/dev/null`
+if [ "$result" = "" ]; then
+   echo "   ERROR"
+else   
+   echo "   PASSED"
+fi
