Index: examples/python_tests/basic_id/README
===================================================================
--- examples/python_tests/basic_id/README	(revision be6cb41674f39a7d7d384be53bbceed738eb6eae)
+++ examples/python_tests/basic_id/README	(revision be6cb41674f39a7d7d384be53bbceed738eb6eae)
@@ -0,0 +1,43 @@
+#####################################################################
+# This example demonstrates various ways to create and access
+# ID credentials using libabac api
+#  
+
+case 1: make ID  -- not in RT0
+        writing cert file
+        writing key file
+        load cert, key file
+
+case 2: make ID  -- not in RT0
+        load ID
+
+case 3: make ID  -- not in RT0?
+        write key to combo file
+        write cert to combo file
+        load combo file
+
+case 4: make ID
+        write key to unconventional name
+        write cert to unconventional name
+        load unconventional filename
+        
+case 5: make ID
+        write cert to combo file
+        load combo file
+
+case 6: make ID
+        write key to combo file
+        load combo file
+
+case 7: make ID
+        extract id chunk cert from ID
+        make another ID with the chunk cert
+        load new ID(as chunk)
+
+case 8: make ID
+        extract id cert chunk from ID
+        load the cert chunk directly into context
+
+case 9: load unknown combo file
+
+
Index: examples/python_tests/basic_id/id.py
===================================================================
--- examples/python_tests/basic_id/id.py	(revision be6cb41674f39a7d7d384be53bbceed738eb6eae)
+++ examples/python_tests/basic_id/id.py	(revision be6cb41674f39a7d7d384be53bbceed738eb6eae)
@@ -0,0 +1,103 @@
+#!/usr/bin/env python
+
+"""
+  to test with python
+
+cmd:env keystore=`pwd` ./id.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) 
+
+## case 1
+## creating and writing out using libabac ID
+id=ABAC.ID("Mary", 0)
+print "adding -> %s(Mary/good)" % id.keyid()
+id.write_cert_file("Mary_ID.pem")
+id.write_privkey_file("Mary_private.pem")
+## load principal with id/key file pair
+## note, with this, we do not have handle on the keyid
+## to Mary but it will be in the db
+#XXX# ctxt.load_id_files("Mary_ID.pem","Mary_private.pem")
+
+## case 2
+## creating principal using ID
+id2=ABAC.ID("Jack2", 0)
+print "adding -> %s(Jack2/good)" % id2.keyid()
+## load principal directly with the ID, no external
+## credential files were created
+#XXX# ctxt.load_id(id2)
+
+## case 3
+## creating principal using ID
+id3=ABAC.ID("Mark", 0)
+print "adding -> %s(Mark/good)" % id3.keyid()
+## write cert and key content to a combo file. One is appended
+## after another
+id3.write_privkey_file("Mark_IDKEY.pem")
+id3.write_cert_file("Mark_IDKEY.pem")
+## load principal in with the combo file with the tandem format
+ctxt.load_id_file("Mark_IDKEY.pem")
+
+## case 4
+## creating principal using ID
+id4=ABAC.ID("John", 0)
+print "adding -> %s(John/good,invisible)" % id4.keyid()
+id4.write_cert_file("John_other.pem")
+## load id without the key file
+ctxt.load_id_file("John_other.pem")
+
+## case 5
+## creating principal using ID
+id5=ABAC.ID("Lori", 0)
+print "adding -> %s(Lori/good,nokey)" % id5.keyid()
+## write just cert into the combo file
+id5.write_cert_file("Lori_IDKEY.pem")
+##load principal from a combo file that only contains cert part
+ctxt.load_id_file("Lori2_IDKEY.pem")
+
+## case 6
+## creating principal using ID
+id6=ABAC.ID("Tom", 0)
+print "adding -> %s(Tom/bad,nocert)" % id6.keyid()
+## write just key into the combo file
+id6.write_privkey_file("Tom_IDKEY.pem")
+## load principal from combo file that only contains key part
+ctxt.load_id_file("Tom_IDKEY.pem")
+
+## case 7
+## creating ID using chunk
+## this already created a Tim with private key and
+## stored in the master list
+id7=ABAC.ID("Tim", 0)
+chunk=id7.cert_chunk() 
+id77=ABAC.ID(chunk)
+## load principal from new id
+ctxt.load_id_chunk(id77.cert_chunk())
+
+## case 8
+## load directly using chunk
+## this already created a Stanley with private key
+## and stored in the master list
+id8=ABAC.ID("Stanley", 0)
+chunk=id8.cert_chunk() 
+## load principal as chunk
+ctxt.load_id_chunk(chunk)
+
+## case 9
+## failure case, loading a non-existing combo file
+print "adding -> Casper(bad,unknown file)"
+ctxt.load_id_file("Casper_IDKEY.pem")
+
Index: examples/python_tests/basic_id/id_ctxt.py
===================================================================
--- examples/python_tests/basic_id/id_ctxt.py	(revision be6cb41674f39a7d7d384be53bbceed738eb6eae)
+++ examples/python_tests/basic_id/id_ctxt.py	(revision be6cb41674f39a7d7d384be53bbceed738eb6eae)
@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+
+"""
+  to test when an id gets loaded into the session
+vs when it gets loaded into a context
+
+cmd:env keystore=`pwd` ./id_ctxt.py 
+
+"""
+
+import os
+import ABAC
+
+def pSZ(CTXT,msg):
+   psz= CTXT.principal_count()
+   csz= CTXT.credential_count()
+   print "context [%s] %d principals, %d credentials" % (msg,psz,csz)
+
+ctxtA = ABAC.Context()
+ctxtB = ABAC.Context()
+
+ABAC.dump_debug_info("first")
+pSZ(ctxtA, "A")
+pSZ(ctxtB, "B")
+
+## creating and writing out using libabac ID
+id=ABAC.ID("Ella", 0)
+print "adding -> %s(good) to session" % id.id_name()
+id.id_write_cert("Ella_ID.pem")
+id.id_write_privkey("Ella_private.pem")
+
+ABAC.dump_debug_info("second")
+pSZ(ctxtA, "A")
+pSZ(ctxtB, "B")
+
+## load principal with id/key file pair
+## note, with this, we do not have handle on the keyid
+## to Ella but it will be in the db
+print "loading -> %s to ctxtA" % id.id_name()
+ctxtA.load_id_files("Ella_ID.pem","Ella_private.pem")
+
+print "loading -> Bob to ctxtB"
+ctxtB.load_id_files("Bob_ID.pem","Bob_private.pem")
+
+ABAC.dump_debug_info("third")
+pSZ(ctxtA, "A")
+pSZ(ctxtB, "B")
Index: examples/python_tests/basic_id/run_test
===================================================================
--- examples/python_tests/basic_id/run_test	(revision be6cb41674f39a7d7d384be53bbceed738eb6eae)
+++ examples/python_tests/basic_id/run_test	(revision be6cb41674f39a7d7d384be53bbceed738eb6eae)
@@ -0,0 +1,21 @@
+#!/bin/sh 
+
+rm -rf *.pem *.xml *.log *.out
+
+echo '---setup principals'
+./setup.py 1>id.log 2>&1
+
+echo '---run id.py '
+env keystore=`pwd` ./id.py > id.out 2>&1
+
+#echo '---run id_ctxt ' -- not in RT0
+#env keystore=`pwd` ./id_ctxt.py >> id.out 2>&1
+
+good=`grep adding id.out |wc -l`
+bad=`grep "terminate called" id.out |wc -l`
+if [ "$good" = "6" -a "$bad" = "1" ]; then
+    echo "   PASSED"
+else
+    echo "   ERROR:basic_id test result differs!!!"
+fi
+
Index: examples/python_tests/basic_id/setup.py
===================================================================
--- examples/python_tests/basic_id/setup.py	(revision be6cb41674f39a7d7d384be53bbceed738eb6eae)
+++ examples/python_tests/basic_id/setup.py	(revision be6cb41674f39a7d7d384be53bbceed738eb6eae)
@@ -0,0 +1,31 @@
+#!/usr/bin/env python
+
+"""
+See README for the semantics.  This creates principals
+using ID and write out the credential file pair, cert/privkey
+"""
+import os
+import ABAC
+
+jackID=ABAC.ID("Jack", 0)
+jackID.write_cert_file("Jack_ID.pem")
+jackID.write_privkey_file("Jack_private.pem")
+
+bobID=ABAC.ID("Bob", 0)
+bobID.write_cert_file("Bob_ID.pem")
+bobID.write_privkey_file("Bob_private.pem")
+
+markID=ABAC.ID("Mark2", 0)
+markID.write_privkey_file("Mark2_IDKEY.pem")
+markID.write_cert_file("Mark2_IDKEY.pem")
+
+johnID=ABAC.ID("John2", 0)
+johnID.write_cert_file("John2_other.pem")
+
+tomID=ABAC.ID("Tom2", 0)
+tomID.write_privkey_file("Tom2_IDKEY.pem")
+
+loriID=ABAC.ID("Lori2", 0)
+loriID.write_cert_file("Lori2_IDKEY.pem")
+
+
