Index: examples/python_tests/basic_id/README
===================================================================
--- examples/python_tests/basic_id/README	(revision 5110d428b9de9f6ec063a033dfe605950456dc4f)
+++ examples/python_tests/basic_id/README	(revision 5110d428b9de9f6ec063a033dfe605950456dc4f)
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+#####################################################################
+# This example demonstrates various ways to access and create 
+# ID credentials using libabac api using python
+# In yap db, the ID credential is stored as: isType(pIDname,keyid)
+
+# Two pre-existing id credentials are generated using creddy, this is
+# to test the load_directory api call
+creddy --generate --cn CreddyBob
+creddy --generate --cn CreddyJack
+
+#  
Index: examples/python_tests/basic_id/id.py
===================================================================
--- examples/python_tests/basic_id/id.py	(revision 5110d428b9de9f6ec063a033dfe605950456dc4f)
+++ examples/python_tests/basic_id/id.py	(revision 5110d428b9de9f6ec063a033dfe605950456dc4f)
@@ -0,0 +1,68 @@
+#!/usr/bin/env python
+
+"""
+  to test with python
+
+cmd1:env keystore=`pwd` ./id.py 
+cmd2:env ABAC_CN=1 keystore=`pwd` ./id.py
+
+"""
+
+import os
+import ABAC
+
+ctxt = ABAC.Context()
+
+print "ABAC version %s" % ctxt.version()
+
+keystore=os.environ["keystore"]
+
+ctxt.load_directory(keystore)
+out = ctxt.context_principals()
+print "...initial principal set..."
+for x in out[1]:
+    print "%s " % x.string()
+print "\n" 
+
+id=ABAC.ID("Mary", 0)
+print "adding -> %s(good)" % id.name()
+id.write_cert("Mary_ID.pem")
+id.write_privkey("Mary_private.pem")
+ctxt.load_id_file("Mary_ID.pem","Mary_private.pem")
+
+nid=ABAC.ID("Jack", 0)
+print "adding -> %s(good)" % nid.name()
+ctxt.load_id(nid)
+
+id=ABAC.ID("Mark", 0)
+print "adding -> %s(good)" % id.name()
+id.write_privkey("Mark_IDKEY.pem")
+id.write_cert("Mark_IDKEY.pem")
+ctxt.load_id_file("Mark_IDKEY.pem")
+
+id=ABAC.ID("John", 0)
+print "adding -> %s(good,invisible)" % id.name()
+id.write_privkey("John_idkey.pem")
+id.write_cert("John_idkey.pem")
+ctxt.load_id_file("John_idkey.pem")
+
+id=ABAC.ID("Lori", 0)
+print "adding -> %s(good,nokey)" % id.name()
+id.write_cert("Lori_IDKEY.pem")
+ctxt.load_id_file("Lori_IDKEY.pem")
+
+id=ABAC.ID("Tom", 0)
+print "adding -> %s(bad,nocert)" % id.name()
+id.write_privkey("Tom_IDKEY.pem")
+ctxt.load_id_file("Tom_IDKEY.pem")
+
+print "adding -> Casper(bad,unknown file)"
+ctxt.load_id_file("Casper_IDKEY.pem")
+
+print "...final principal set..."
+out = ctxt.context_principals()
+for x in out[1]:
+    print "%s " % x.string()
+print "\n"
+
+ctxt.dump_yap()
Index: examples/python_tests/basic_id/id.save
===================================================================
--- examples/python_tests/basic_id/id.save	(revision 5110d428b9de9f6ec063a033dfe605950456dc4f)
+++ examples/python_tests/basic_id/id.save	(revision 5110d428b9de9f6ec063a033dfe605950456dc4f)
@@ -0,0 +1,59 @@
+% Restoring file /usr/local/lib/Yap/startup.yss
+python: Couldn't load ID/KEY IDKEY cert /home/mei/Deter/abac/examples/python_tests/basic_id/Tom_IDKEY.pem
+ABAC version 1.0
+...initial principal set...
+(pCreddyBob,keyid,y) 
+(pCreddyJack,keyid,y) 
+(pMary,keyid,y) 
+(pLori,keyid,n) 
+(pMark,keyid,y) 
+
+
+adding -> pMary(good)
+adding -> pJack(good)
+adding -> pMark(good)
+adding -> pJohn(good,invisible)
+adding -> pLori(good,nokey)
+adding -> pTom(bad,nocert)
+adding -> Casper(bad,unknown file)
+...final principal set...
+(pCreddyBob,keyid,y) 
+(pCreddyJack,keyid,y) 
+(pMary,keyid,y) 
+(pLori,keyid,n) 
+(pMark,keyid,y) 
+(pJack,keyid,y) 
+(pJohn,keyid,y) 
+
+
+
+
+========= yap db (dump_yap)
+isType(pCreddyBob,keyid).
+isType(pCreddyJack,keyid).
+isType(pMary,keyid).
+isType(pLori,keyid).
+isType(pMark,keyid).
+isType(pJack,keyid).
+isType(pJohn,keyid).
+appendL([],[]).
+appendL([B|C],A) :-
+   appendL(C,D),
+   append(B,D,A).
+append([],A,A).
+append([B|C],A,[B|D]) :-
+   append(C,A,D).
+file_search_path(library,A) :-
+   library_directory(A).
+file_search_path(commons,_) :-
+   commons_directory(_).
+file_search_path(swi,A) :-
+   current_prolog_flag(home,A).
+file_search_path(yap,A) :-
+   current_prolog_flag(home,A).
+file_search_path(system,A) :-
+   prolog_flag(host_type,A).
+file_search_path(foreign,yap('lib/Yap')).
+listing ok.. 
+========= 
+
Index: examples/python_tests/basic_id/run_test
===================================================================
--- examples/python_tests/basic_id/run_test	(revision 5110d428b9de9f6ec063a033dfe605950456dc4f)
+++ examples/python_tests/basic_id/run_test	(revision 5110d428b9de9f6ec063a033dfe605950456dc4f)
@@ -0,0 +1,30 @@
+#!/bin/sh 
+
+ABAC_PROVER_PATH="/home/mei/Deter/abac/libabac"
+export ABAC_PROVER_PATH
+
+g_cmd_sha=`grep "cmd1:" id.py |sed "s/cmd1://g" `
+g_cmd_cn=`grep "cmd2:" id.py |sed "s/cmd2://g" `
+
+echo '---setup principals'
+./README
+
+echo '---run with sha'
+eval $g_cmd_sha 2>/dev/null 1 > id.sha
+
+echo '---run with cn'
+eval $g_cmd_cn 1>id.cn 2>&1
+result=`diff id.cn id.save 2>/dev/null`
+if [ $? -eq 0 ]; then
+    if [ "$result" = "" ]; then
+       echo "   PASSED"
+    else
+       echo "   ERROR:id test result differs!!!"
+    fi
+else
+    echo "   ERROR:id test result differs!!!"
+fi
+
+
+
+
