Index: examples/example_scripts/Makefile
===================================================================
--- examples/example_scripts/Makefile	(revision a59bc0664482631699a51d4a27d327830f6df77e)
+++ examples/example_scripts/Makefile	(revision a334115350f4575c5e7515b0c17a273a10685e4d)
@@ -1,4 +1,4 @@
 
-DIRECTORY=c perl python
+DIRECTORY=c perl python java
 
 .PHONY : runcheck clean 
Index: examples/example_scripts/allout.save
===================================================================
--- examples/example_scripts/allout.save	(revision a59bc0664482631699a51d4a27d327830f6df77e)
+++ examples/example_scripts/allout.save	(revision a334115350f4575c5e7515b0c17a273a10685e4d)
@@ -27,2 +27,8 @@
 ---running (python) prover script
    PASSED
+
+ ==> RUN on java
+---running (java) attr script
+   PASSED
+---running (java) prover script
+   PASSED
Index: examples/example_scripts/c/Makefile
===================================================================
--- examples/example_scripts/c/Makefile	(revision a59bc0664482631699a51d4a27d327830f6df77e)
+++ examples/example_scripts/c/Makefile	(revision a334115350f4575c5e7515b0c17a273a10685e4d)
@@ -19,4 +19,9 @@
 	gcc -g -o abac_prover abac_prover.o -L/usr/local/lib -L/usr/local/lib/ipsec -labac -lYap -lreadline -lm -lstrongswan -Wl,-rpath -Wl,/usr/local/lib/ipsec
 
+tchunk: tchunk.c
+	gcc -g -I/usr/local/include -c tchunk.c -o tchunk.o
+	gcc -g -o tchunk tchunk.o -L/usr/local/lib -L/usr/local/lib/ipsec -labac -lYap -lreadline -lm -lstrongswan -Wl,-rpath -Wl,/usr/local/lib/ipsec
+	./tchunk 0 IceCream_ID.pem IceCream_private.pem
+	./tchunk 1 IceCream_ID.pem IceCream_private.pem
 
 clean:
Index: examples/example_scripts/c/tchunk.c
===================================================================
--- examples/example_scripts/c/tchunk.c	(revision a334115350f4575c5e7515b0c17a273a10685e4d)
+++ examples/example_scripts/c/tchunk.c	(revision a334115350f4575c5e7515b0c17a273a10685e4d)
@@ -0,0 +1,44 @@
+/**
+   tt.c
+
+**/
+
+#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[2]);
+    int rc=abac_id_load_privkey_file(id,argv[3]);
+
+    int w=atoi(argv[1]);
+    if(w==0) {
+        printf("USING chunk...\n");
+        rc=abac_context_load_id_privkey_chunk(ctx, 
+                  abac_id_cert_chunk(id), 
+                  abac_id_privkey_chunk(id));
+    } else {
+        printf("USING NO chunk...\n");
+        rc=abac_context_load_id_id(ctx, id);  
+    }
+
+    show_yap_db("dump_yap");
+    abac_context_free(ctx);
+    return 0;
+}
Index: examples/example_scripts/java/Makefile
===================================================================
--- examples/example_scripts/java/Makefile	(revision a334115350f4575c5e7515b0c17a273a10685e4d)
+++ examples/example_scripts/java/Makefile	(revision a334115350f4575c5e7515b0c17a273a10685e4d)
@@ -0,0 +1,25 @@
+
+all: run_attr run_prove
+
+clean:
+	@rm -f *.pem *.der *.log pfile 
+	@rm -rf build *.class
+
+
+run_attr: 
+	make clean
+	rm -rf attr.log
+	ant
+	javac -classpath ./build/classes abac_attr.java
+	java -classpath ./build/classes:. abac_attr 1 >attr.log 2>&1
+
+run_prove:
+	rm -rf prover.log
+	make run_attr
+	./run_prover 1 >prover.log 2>& 1
+
+tchunk:
+	make clean
+	javac -classpath ./build/classes tchunk.java
+	java -classpath ./build/classes:. tchunk 1 IceCream_ID.pem IceCream_private.pem 
+	java -classpath ./build/classes:. tchunk 0 IceCream_ID.pem IceCream_private.pem 
Index: examples/example_scripts/java/abac_attr.java
===================================================================
--- examples/example_scripts/java/abac_attr.java	(revision a334115350f4575c5e7515b0c17a273a10685e4d)
+++ examples/example_scripts/java/abac_attr.java	(revision a334115350f4575c5e7515b0c17a273a10685e4d)
@@ -0,0 +1,79 @@
+/*****
+     abac_attr.java
+
+     To demonstrate how to use ABAC's api in java 
+  
+     call:   abac_attr IceCream_ID.pem IceCream_private.pem IceCream_attr.der Chocolate_ID.pem
+  
+     This program will generate 2 principal credentials, (IceCream, Chocolate) and
+             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
+***/
+
+import java.io.*;
+import java.util.*;
+
+import net.deterlab.abac.*;
+
+public class abac_attr {
+
+    static {
+        System.loadLibrary("jABAC");
+    }
+
+    public static void main(String[] args) {
+        Context ctxt=new Context();
+
+        ID iceID=new ID("IceCream",0);
+        iceID.id_write_cert("IceCream_ID.pem");
+        iceID.id_write_privkey("IceCream_private.pem");
+
+        ID chocoID=new ID("Chocolate",0);
+        chocoID.id_write_cert("Chocolate_ID.pem");
+        chocoID.id_write_privkey("Chocolate_private.pem");
+        ctxt.load_id(chocoID);
+
+        ctxt.load_id_chunks(iceID.id_cert_chunk(), iceID.id_privkey_chunk());
+        /*or,  ctxt.load_id(iceID); */
+
+        /* create an attribute cert
+               iceCream.delicous <- chocolate */
+        Role head= new Role(iceID.id_keyid(),"delicious");
+        Role tail= new Role(chocoID.id_keyid());
+
+        Attribute attr = new Attribute(head, 1800);
+        attr.attribute_add_tail(tail);
+        attr.attribute_bake();
+
+        /* write it out */
+        attr.attribute_write_cert("IceCream_attr.der");
+
+        /* load attribute cert into the context */
+        ctxt.load_attribute_chunk(attr.cert_chunk());
+        /* or, ctxt.load_attribute(attr); */
+
+        /* what is in prolog db  
+        ctxt.dump_yap_db(); */
+
+        AttributeVector credentials = ctxt.query(head, tail);
+        long sz=credentials.size();
+        if(sz > 0)
+            System.out.println("prover success!!");
+        else
+            System.out.println("prover failed!!");
+
+        for(int i=0; i<sz; i++) {
+            Attribute c=credentials.get(i);
+            System.out.println(c.head_string()+"<- "+c.tail_string());
+        }
+        System.out.println("called main from abac_attr.java");
+
+    }
+}
+
Index: examples/example_scripts/java/build.xml
===================================================================
--- examples/example_scripts/java/build.xml	(revision a334115350f4575c5e7515b0c17a273a10685e4d)
+++ examples/example_scripts/java/build.xml	(revision a334115350f4575c5e7515b0c17a273a10685e4d)
@@ -0,0 +1,48 @@
+<!--
+  Project file for ant to build java ABAC library and test cases.  
+  Requires Jung and bouncycastle.
+
+  Targets:
+    all: clean then compile and make docs
+    compile: build the library and test programs
+    jar: build jabac.jar in build/jar/jabac.jar
+    clean: remove created files
+-->
+
+<project name="jABAC" default="all">
+
+  <property name="src.dir" value="../../../swig/java"/>
+  <property name="lib.dir" value="/usr/local/lib"/>
+  <property name="build.dir" value="build"/>
+  <property name="classes.dir" value="${build.dir}/classes"/>
+  <property name="jar.dir" value="${build.dir}/jar"/>
+  <property name="version" value="0.2.3"/>
+
+  <path id="compile.classpath">
+    <fileset dir="${lib.dir}" includes="**/*.jar"/>
+  </path>
+
+  <target name="all" depends="clean, compile, jar "
+    description="Clean then build" />
+
+  <target name="clean">
+    <delete dir="${build.dir}"/>
+  </target>
+
+  <target name="compile" description="Compile the source">
+    <mkdir dir="${classes.dir}" />
+    <javac srcdir="${src.dir}" destdir="${classes.dir}" 
+      classpathref="compile.classpath" includeAntRuntime="no" excludes="**/prover_test.java **/abac_attr.java **/ProverTest.java **/SetupTest.java"/>
+  </target>
+
+  <target name="jar" depends="compile" description="Make a jar">
+    <mkdir dir="${jar.dir}"/>
+    <jar destfile="${jar.dir}/jabac-${version}.jar" basedir="${classes.dir}"
+      excludes="**/prover_test.class **/abac_attr.class">
+      <manifest>
+	<attribute name="Class-Path" value="${classpath}" />
+      </manifest>
+    </jar>
+  </target>
+
+</project>
Index: examples/example_scripts/java/prover_test.java
===================================================================
--- examples/example_scripts/java/prover_test.java	(revision a334115350f4575c5e7515b0c17a273a10685e4d)
+++ examples/example_scripts/java/prover_test.java	(revision a334115350f4575c5e7515b0c17a273a10685e4d)
@@ -0,0 +1,67 @@
+import java.io.*;
+import java.util.*;
+
+import net.deterlab.abac.*;
+
+/**
+ * Simple test of the swig generated JNI for libabac. Loads credentials
+ * from keystore and runs a query against them.
+ */
+public class prover_test {
+
+    static {
+        System.loadLibrary("jABAC");
+    }
+
+    public static void main(String[] args) throws IOException {
+        if (args.length != 4) {
+            System.out.println("Usage: prover_test <keystore> <issuer> <roletype> <principal>");
+            System.out.println("    runs the query issuer.role <-?- principal and prints the result"
+);
+            System.exit(1);
+        }
+
+        Context ctxt = new Context();
+
+        String keystore=args[0];
+        String iname=args[1];
+        String roletype=args[2];
+        String pname=args[3];
+
+/*
+role="[keyid:${pID}].role:delicious"
+principal="[keyid:${cID}]"
+*/
+        String ifname=iname+"_ID.pem";
+        String pfname=pname+"_ID.pem";
+
+        ID iID=new ID(ifname);
+        ID pID=new ID(pfname);
+
+        String ikeyid=iID.id_keyid();
+        String pkeyid=pID.id_keyid();
+
+        String role="[keyid:"+ikeyid+"].role:"+roletype;
+        String principal="[keyid:"+pkeyid+"]";
+
+        ctxt.load_directory(keystore);
+
+        /* what is in prolog db 
+        ctxt.dump_yap_db(); */
+
+        AttributeVector credentials = ctxt.query(role, principal);
+
+        long sz=credentials.size();
+ 
+        if(sz > 0)
+            System.out.println("prover success!!");
+        else
+            System.out.println("prover failed!!");
+
+        for(int i=0; i<sz; i++) {
+            Attribute c=credentials.get(i);
+            System.out.println(c.head_string()+"<- "+c.tail_string());
+        }
+        System.out.println("called main from prover_test.java");
+    }
+}
Index: examples/example_scripts/java/run_prover
===================================================================
--- examples/example_scripts/java/run_prover	(revision a334115350f4575c5e7515b0c17a273a10685e4d)
+++ examples/example_scripts/java/run_prover	(revision a334115350f4575c5e7515b0c17a273a10685e4d)
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+rm -rf hs_*.log
+
+keystore=`pwd`
+
+javac -classpath ${keystore}/build/classes prover_test.java
+
+java -classpath ${keystore}/build/classes:. -Djava.library.path=/usr/local/lib prover_test ${keystore} IceCream delicious Chocolate
Index: examples/example_scripts/java/run_test
===================================================================
--- examples/example_scripts/java/run_test	(revision a334115350f4575c5e7515b0c17a273a10685e4d)
+++ examples/example_scripts/java/run_test	(revision a334115350f4575c5e7515b0c17a273a10685e4d)
@@ -0,0 +1,22 @@
+#!/bin/sh 
+
+make -s clean
+
+echo '---running (java) attr script'
+make run_attr 1>/dev/null 2>& 1
+result=`grep "prover success" attr.log 2>/dev/null`
+if [ "$result" = "" ]; then
+   echo "   ERROR"
+else   
+   echo "   PASSED"
+fi
+
+echo '---running (java) prover script'
+make run_prove 1>/dev/null 2>& 1
+result=`grep "prover success" prover.log 2>/dev/null`
+if [ "$result" = "" ]; then
+   echo "   ERROR"
+else   
+   echo "   PASSED"
+fi
+
Index: examples/example_scripts/java/tchunk.java
===================================================================
--- examples/example_scripts/java/tchunk.java	(revision a334115350f4575c5e7515b0c17a273a10685e4d)
+++ examples/example_scripts/java/tchunk.java	(revision a334115350f4575c5e7515b0c17a273a10685e4d)
@@ -0,0 +1,43 @@
+/*****
+     tchunk.java
+***/
+
+import java.io.*;
+import java.util.*;
+
+import net.deterlab.abac.*;
+
+public class tchunk {
+
+    static {
+        System.loadLibrary("jABAC");
+    }
+
+    public static void main(String[] args) throws IOException {
+
+        String w=args[0];
+        String icecreamID=args[1];
+        String icecreamKEY=args[2];
+
+        Context ctxt=new Context();
+
+        ID id=new ID(icecreamID);
+        id.id_load_privkey_file(icecreamKEY);
+
+        ctxt.load_id(id);
+        if(w.equals("0")) {
+            System.out.println("USING chunk...");
+            ctxt.load_id_chunks(id.id_cert_chunk(), id.id_privkey_chunk());
+        } else {
+            System.out.println("USING NO chunk...");
+            ctxt.load_id(id);
+        }
+
+        /* what is in prolog db */
+        ctxt.dump_yap_db(); 
+
+        System.out.println("called main from tchunk.java");
+
+    }
+}
+
