Index: examples/example_scripts/.runall
===================================================================
--- examples/example_scripts/.runall	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
+++ examples/example_scripts/.runall	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
@@ -0,0 +1,37 @@
+#!/bin/sh 
+
+# format,
+#   runall clean
+#   runall run
+
+progname=$(basename $0)
+pwd=`pwd`
+
+if [ $# -eq 0 ]; then
+    echo "Usage: $progname (clean|run)" >&2;
+    exit 1
+fi
+
+ABAC_PROVER_PATH=`which abac_prover_yap | sed 's/\/abac_prover_yap//'`
+export ABAC_PROVER_PATH
+
+if [ "$1" = "clean" ]; then
+    rm -rf allout.tmp 
+    for i in `ls -1 `; do
+        if [ -d $i ]; then
+            printf "\n ==> CLEANING on %s\n" "$i" >& 2 ;
+            cd $i
+            make realclean
+            cd $pwd
+        fi
+    done
+elif [ "$1" = "run" ] ; then
+    for i in `ls -1 `; do
+        if [ -d $i ]; then
+            printf "\n ==> RUN on %s\n" "$i" ;
+            cd $i
+            ./run_test
+            cd $pwd
+        fi
+    done
+fi 
Index: examples/example_scripts/README
===================================================================
--- examples/example_scripts/README	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
+++ examples/example_scripts/README	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
@@ -0,0 +1,11 @@
+
+
+This directory does regression testing of
+example scripts that were under libabac's swig 
+directory
+
+
+to run,  
+   
+   runcheck
+
Index: examples/example_scripts/allout.save
===================================================================
--- examples/example_scripts/allout.save	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
+++ examples/example_scripts/allout.save	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
@@ -0,0 +1,20 @@
+
+ ==> RUN on c
+---running (c) attr script
+   PASSED
+
+ ==> RUN on perl
+---running (perl) id script
+   PASSED
+---running (perl) id script, expected failure
+   PASSED
+
+ ==> RUN on python
+---running (python) attr script
+   PASSED
+---running (python) encrypted key attr script
+   PASSED
+---running (python) id script
+   PASSED
+---running (python) id script, expect failure
+   PASSED
Index: examples/example_scripts/allout.tmp
===================================================================
--- examples/example_scripts/allout.tmp	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
+++ examples/example_scripts/allout.tmp	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
@@ -0,0 +1,20 @@
+
+ ==> RUN on c
+---running (c) attr script
+   PASSED
+
+ ==> RUN on perl
+---running (perl) id script
+   PASSED
+---running (perl) id script, expected failure
+   PASSED
+
+ ==> RUN on python
+---running (python) attr script
+   ERROR
+---running (python) encrypted key attr script
+   ERROR
+---running (python) id script
+   ERROR
+---running (python) id script, expect failure
+   ERROR
Index: examples/example_scripts/c/IceCream_ID.pem
===================================================================
--- examples/example_scripts/c/IceCream_ID.pem	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
+++ examples/example_scripts/c/IceCream_ID.pem	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
@@ -0,0 +1,19 @@
+-----BEGIN CERTIFICATE-----
+MIIDDDCCAfSgAwIBAgIJAOL+hAXOfMFzMA0GCSqGSIb3DQEBBQUAMBMxETAPBgNV
+BAMTCEljZUNyZWFtMB4XDTEyMDgwNDAzNDU1NVoXDTE1MDcyMDAzNDU1NVowEzER
+MA8GA1UEAxMISWNlQ3JlYW0wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB
+AQDF09d/LF1LwztFp9wIAAqhl5YTxiyui8L8uZf8OgZgjcukoWYhbjsrKgSE3goX
+920hmwAVqysSVQgANuERl1BFqYEEYrFfheBJCgDoC1rRzj1RanzKpovWtFbrYj6j
+pekhW9eM8pgVsSUOpugT00/1a3/G0BxMl5sJPMhx9wEB8Os2izqt2zW99EipG1wu
+O8IS71UWc26iX2wOLExvqRw3+JZpjgH7INAmpHhlv5QzbvjOUnseCiN8KlNUCaVg
+p9ebpyiOoB8BXmc/fWJZoYo6MLJOXIhbmIWVWX6niq9QMpX0tkpbxqcTMQd0Gw4I
+tEuKWE7dfgCf6l/l2lQPty+nAgMBAAGjYzBhMA8GA1UdEwEB/wQFMAMBAf8wDgYD
+VR0PAQH/BAQDAgEGMB0GA1UdDgQWBBS6DqZYBGAzDo9EXpd9aL+joNOh6TAfBgNV
+HSMEGDAWgBS6DqZYBGAzDo9EXpd9aL+joNOh6TANBgkqhkiG9w0BAQUFAAOCAQEA
+VNiv597HGrPtgEAaCUTWF3XzZMkXHf5SMbokuB3L66Ih4HBtPTZvDs0BfLjWK56B
+WZt+4v0tjY+g5C57OIxNi5ycO7Cpjt1e6ZZlLuiBpbn25cRT2/mfMErSlye8GnNK
+9WKhTT4fILu7PEbjaRfVa5BIaVlmaRKHyBYdNZlsCENzT7gGK2RAHaa0NHkJg+mR
+R/xJb+2edUOca+1s+NnG/macSvg8dUkw8uhqBxnCPHBFQCGTv+JIsdJ6yH5pc4XV
+ISoEWi1DewxlP3g6ZA6Nm9IOeJhiGR4jLKwr2cBjXz4vn9AxP2ohpAMzDi3OjQA6
+dGg5wyrxk8qvUbaBxxwa9A==
+-----END CERTIFICATE-----
Index: examples/example_scripts/c/IceCream_private.pem
===================================================================
--- examples/example_scripts/c/IceCream_private.pem	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
+++ examples/example_scripts/c/IceCream_private.pem	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
@@ -0,0 +1,27 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIEpgIBAAKCAQEAxdPXfyxdS8M7RafcCAAKoZeWE8YsrovC/LmX/DoGYI3LpKFm
+IW47KyoEhN4KF/dtIZsAFasrElUIADbhEZdQRamBBGKxX4XgSQoA6Ata0c49UWp8
+yqaL1rRW62I+o6XpIVvXjPKYFbElDqboE9NP9Wt/xtAcTJebCTzIcfcBAfDrNos6
+rds1vfRIqRtcLjvCEu9VFnNuol9sDixMb6kcN/iWaY4B+yDQJqR4Zb+UM274zlJ7
+HgojfCpTVAmlYKfXm6cojqAfAV5nP31iWaGKOjCyTlyIW5iFlVl+p4qvUDK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Ruf12EMf6p45nQTNYHbakEM+w5u+pMDx1c+kezcSVv52X
+jv595qMBAoGBANRUTXrllmKOj5l2WGdsfCBiLpOlCkjMlGSDgb/Nr6Dbymi6nw5i
+XdGKJcauXVr2sMyWVjKAIqW9C5Hj+BuTW3rHpav+OKk6FE4S52sJthGfG5j98iXj
+EC9c1HY8gr7A/XXFOqOG7Qs0Kl7P2lXMYaQLNFExtKHYYelTHnJ++QPb
+-----END RSA PRIVATE KEY-----
Index: examples/example_scripts/c/Makefile
===================================================================
--- examples/example_scripts/c/Makefile	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
+++ examples/example_scripts/c/Makefile	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
@@ -0,0 +1,19 @@
+all: run
+
+abac_attr.o: abac_attr.c
+	gcc -g -c abac_attr.c -o abac_attr.o
+
+abac_attr: abac_attr.o
+	gcc -g -o abac_attr abac_attr.o -L/usr/local/lib/ipsec -labac -lYap -lreadline -lm -lstrongswan -Wl,-rpath -Wl,/usr/local/lib/ipsec
+
+clean:
+	rm -f abac_attr.o abac_attr *.pem *.der *.log
+
+realclean: 
+	make clean
+
+run: abac_attr
+	make clean
+	creddy --generate --cn IceCream
+	make abac_attr
+	./abac_attr IceCream_ID.pem  IceCream_private.pem IceCream_attr.der 1>attr.log 2>&1
Index: examples/example_scripts/c/abac_attr.c
===================================================================
--- examples/example_scripts/c/abac_attr.c	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
+++ examples/example_scripts/c/abac_attr.c	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
@@ -0,0 +1,87 @@
+/**
+   attr_abac.c
+
+   To demonstrate how to use ABAC's api in C
+
+   call:   attr_abac IceCream_ID.pem IceCream_private.pem IceCream_attr.der
+
+   pre-condition: generate IceCream_ID.pem and IceCream_private.pem with
+           creddy --generate --cn IceCream
+
+   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:IceCream]
+
+   Then, a query is made against the context to see if it is populated correctly.
+
+**/
+
+#include <err.h>
+#include <stdio.h>
+#include <assert.h>
+
+#include <abac.h>
+
+extern void abac_print_cred_info(abac_credential_t*, FILE*);
+extern char *abac_id_keyid(abac_id_t *id);
+extern abac_attribute_t *abac_attribute_add_tail(abac_attribute_t *ptr, abac_aspect_t *);
+
+int main(int argc, char **argv) {
+    int i, success=0;
+    abac_credential_t *cred=NULL;
+    abac_credential_t **credentials=NULL;
+
+    abac_context_t *ctx = abac_context_new();
+
+    if(argc != 4) return 1;
+
+    /* build up structure */
+    abac_id_t *id =NULL;
+    id = abac_id_from_file(argv[1]);
+    int rc=abac_id_load_privkey_file(id,argv[2]);
+
+    rc=abac_context_load_id_privkey_chunk(ctx, 
+                  abac_id_cert_chunk(id), 
+                  abac_id_privkey_chunk(id));
+
+    abac_aspect_t *head=abac_role_create(abac_id_keyid(id),"delicious");
+    abac_aspect_t *tail=abac_role_principal_create(abac_id_keyid(id));
+    abac_attribute_t *attr;
+    rc=abac_attribute_create(&attr, head, NULL, 1800);
+    abac_attribute_add_tail(attr, tail);
+    rc=abac_attribute_bake(attr);
+
+    printf(" attribute being made : %s\n",abac_attribute_string(attr));
+
+    abac_attribute_write_cert_fname(attr,argv[3]);
+    abac_context_load_attribute_chunk(ctx,abac_attribute_cert_chunk(attr));
+
+    
+    /* make a query */
+    abac_aspect_t *q=abac_role_create(abac_id_keyid(id),"delicious");
+    abac_aspect_t *w=abac_role_principal_create(abac_id_keyid(id));
+    char *with=abac_aspect_typed_string(w);
+    char *query=abac_aspect_typed_string(q);
+
+    if(query !=NULL && with!=NULL) {
+        credentials = abac_context_query(ctx,
+                            query, with,
+                            &success);
+        if (success)
+            puts("prover success!!");
+            else puts("prover failed!!");
+
+        if (credentials != NULL && success) {
+            puts("credentials needed :");
+            for (i = 0; credentials[i] != NULL; ++i) {
+               cred = credentials[i];
+               abac_print_cred_info(cred,NULL);
+            }
+        }
+        if(credentials)
+            abac_context_credentials_free(credentials);
+    }
+
+    abac_context_free(ctx);
+    return 0;
+}
Index: examples/example_scripts/c/attr.log
===================================================================
--- examples/example_scripts/c/attr.log	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
+++ examples/example_scripts/c/attr.log	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
@@ -0,0 +1,6 @@
+% Restoring file /usr/local/lib/Yap/startup.yss
+ attribute being made : ba0ea6580460330e8f445e977d68bfa3a0d3a1e9.delicious<-ba0ea6580460330e8f445e977d68bfa3a0d3a1e9
+YAP query succeed
+prover success!!
+credentials needed :
+ ba0ea6580460330e8f445e977d68bfa3a0d3a1e9.delicious  <- ba0ea6580460330e8f445e977d68bfa3a0d3a1e9 
Index: examples/example_scripts/c/run_test
===================================================================
--- examples/example_scripts/c/run_test	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
+++ examples/example_scripts/c/run_test	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
@@ -0,0 +1,11 @@
+#!/bin/sh 
+
+echo '---running (c) attr script'
+make run 1>/dev/null 2>& 1
+result=`grep "prover success" attr.log 2>/dev/null`
+if [ "$result" = "" ]; then
+   echo "   ERROR"
+else   
+   echo "   PASSED"
+fi
+
Index: examples/example_scripts/perl/IceCream_ID.pem
===================================================================
--- examples/example_scripts/perl/IceCream_ID.pem	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
+++ examples/example_scripts/perl/IceCream_ID.pem	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
@@ -0,0 +1,19 @@
+-----BEGIN CERTIFICATE-----
+MIIDDDCCAfSgAwIBAgIJAP5qi+Yg3YR6MA0GCSqGSIb3DQEBBQUAMBMxETAPBgNV
+BAMTCEljZUNyZWFtMB4XDTEyMDgwNDAzNDYwMFoXDTE1MDcyMDAzNDYwMFowEzER
+MA8GA1UEAxMISWNlQ3JlYW0wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB
+AQDuN5ij6TYzFR7TETkSzy8pWVifbWgbqI/K3je0m5mqTLBOiO8HLZwVXRdr0tMw
+eB02PRkEaa1kzHugKVghXhzDUjKUCW7LknD+EntrUKlnN6sfiDBI9Sv8w90dQ/yU
+L70vStQq9gkaHvaJQFtk/SF5znexQd618/KAyHPJeWDl3rMAHWAmIJULIx4kbwFS
+fSy5qUkI32UJ5kyoNXPdnTPP3TxHEfr2XqbYexDJBncIN2jSrpSCFEZh42Ga1sW9
+onJ5gNb69IS3HnReNO7zpL2hV2IAEdio9k8gkjFcQr9VkAwd7konz2R8n6Yy1nSR
+tGKESnnWKD4g/94m6dhAsf+7AgMBAAGjYzBhMA8GA1UdEwEB/wQFMAMBAf8wDgYD
+VR0PAQH/BAQDAgEGMB0GA1UdDgQWBBSxT+wg+QKJWxhsO5qwQe2WnPJwfzAfBgNV
+HSMEGDAWgBSxT+wg+QKJWxhsO5qwQe2WnPJwfzANBgkqhkiG9w0BAQUFAAOCAQEA
+Z7KJYJe4X5vR4sYiVkaySRliSLhB2+NvromOmUuvQY3fvtZVWlvDcEWQpp7OSCJx
+1y3fMMZFdrQGPWiHAUZX4WdplzsO1TG208p0jqSJaQjclnUcT2Vb6E1ViDVude9W
+xhaPgKI+wzeECsSN29GUBeNtG9EAGm5POIWrWtx33g3fgzDw5vmtLGV+T7/OWXMR
+6w0n0sLZ5soqa0GSDMqL+/ZrkllqoFSyYMlswHlsZKn6ta/tIAUeYBIwTQsqVuwK
+JetIavMeFNFxfUEEn5WZUgkGtc8X2/d25FfsVH3iG4NCmmFqvUQMro+rJUi0rp5j
+WNNA9b0mcL6OLlwmt82HCQ==
+-----END CERTIFICATE-----
Index: examples/example_scripts/perl/IceCream_private.pem
===================================================================
--- examples/example_scripts/perl/IceCream_private.pem	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
+++ examples/example_scripts/perl/IceCream_private.pem	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
@@ -0,0 +1,27 @@
+-----BEGIN RSA PRIVATE KEY-----
+MI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A4KMCgYALVJ2hBXCvJb+/VQn99pzu
+vIx3YQj12k12W1AiGflY6SC9H7iAF45HdsyIQNyq1me0AZtMdxt0pBQE4NUjnXu+
+F7vlq1+7SVITJsORj0D9rsTrwhqvTrcDfWY36gOPOPNXYA1H3STARwc+aNWyKNrn
+BV07sT/WMgH8FUN4l71o0QKBgESQzUS+t8Om24aOlfbZ3TYeizAcZQrkyN0nWbq6
+hBIlvQ8cRqky2e3jEZlXN0bJT5ptOD4qWT2vzGM42DMQVBQFW+0HhlXM1b+h1VmI
+9xj5EUGQRjBA1gMC573ey/oQmqK/ardmlmtvYqfCVIPjdVXPN3X/L9e9gMWPtCpr
+lqpPAoGBAOufAucJga/80qSfzPjC3NlKJ20pjC/ijG2K630grAqa7WDg0KjLk5IH
+hXy9bXMUq/dNEbm3r0fCC05XfRdY6wnQghthvcgvX3/3SdDA74XXTwOg7f0NlSCr
+UEMgsnQbAHt3Sf6sIBMfffPv9HBcyft1aUGPWGXk34jqRTBmI4vY
+-----END RSA PRIVATE KEY-----
Index: examples/example_scripts/perl/Makefile
===================================================================
--- examples/example_scripts/perl/Makefile	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
+++ examples/example_scripts/perl/Makefile	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
@@ -0,0 +1,16 @@
+clean:
+	rm -f *.pem *.der 
+
+realclean:
+	rm -rf *.pem *.der *.log
+
+run: 
+	make clean
+	rm -rf id.log
+	creddy --generate --cn IceCream
+	./abac_keyid.pl IceCream_ID.pem 1>id.log 2>&1 
+bad: 
+	make clean
+	rm -rf id2.log
+	creddy --generate --cn IceCream
+	./abac_keyid.pl IceCream_private.pem 1>id2.log 2>&1 
Index: examples/example_scripts/perl/abac_keyid.pl
===================================================================
--- examples/example_scripts/perl/abac_keyid.pl	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
+++ examples/example_scripts/perl/abac_keyid.pl	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
@@ -0,0 +1,17 @@
+#!/usr/bin/perl
+
+use ABAC;
+
+my $filename = shift || die "Usage: abac_keyid.pl <cert.pem>\n";
+
+my $id;
+eval {
+    # will throw a RuntimeException if it can't load the cert
+    $id = ABAC::ID->new($filename);
+};
+if ($@) {
+    print "ERROR, Problem loading cert: $@";
+    exit;
+}
+
+print $id->id_keyid, "    OKAY\n";
Index: examples/example_scripts/perl/id.log
===================================================================
--- examples/example_scripts/perl/id.log	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
+++ examples/example_scripts/perl/id.log	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
@@ -0,0 +1,1 @@
+e3f7a5ceeb2d8f816aebbbcf0054bbc03732b8d6    OKAY
Index: examples/example_scripts/perl/id2.log
===================================================================
--- examples/example_scripts/perl/id2.log	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
+++ examples/example_scripts/perl/id2.log	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
@@ -0,0 +1,3 @@
+OpenSSL X.509 parsing failed
+building CRED_CERTIFICATE - X509 failed, tried 4 builders
+perl: Id creation from filename failed
Index: examples/example_scripts/perl/run_test
===================================================================
--- examples/example_scripts/perl/run_test	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
+++ examples/example_scripts/perl/run_test	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
@@ -0,0 +1,19 @@
+#!/bin/sh 
+
+echo '---running (perl) id script'
+make run 1>/dev/null 2>& 1
+result=`grep OKAY id.log 2>/dev/null`
+if [ "$result" = "" ]; then
+   echo "   ERROR"
+else   
+   echo "   PASSED"
+fi
+
+echo '---running (perl) id script, expected failure'
+make bad 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
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
Index: examples/example_scripts/runcheck
===================================================================
--- examples/example_scripts/runcheck	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
+++ examples/example_scripts/runcheck	(revision ba6027a0fac78c4a2e819aabd3ccc80779620acc)
@@ -0,0 +1,20 @@
+#!/bin/sh 
+
+rm -rf allout.tmp
+
+./.runall clean 1 >/dev/null 2>&1
+./.runall setup
+
+ABAC_PROVER_PATH=`which abac_prover_yap | sed 's/\/abac_prover_yap//'`
+export ABAC_PROVER_PATH
+
+echo '\n'
+echo 'running libabac SCRIPT testing...'
+./.runall run 1> allout.tmp 2>/dev/null
+result=`diff allout.tmp allout.save`
+
+if [ "$result" = "" ]; then
+   echo "   PASSED"
+else
+   echo "   ERROR:got changes!!!"
+fi
