Index: java/CreateExample.java
===================================================================
--- java/CreateExample.java	(revision aaadefdebc0a912001992bfef4738f6f1fcc007c)
+++ java/CreateExample.java	(revision 6b31de638ea19a82f4b9aaaa67d2bcfb4d3f7e88)
@@ -6,4 +6,5 @@
 import net.deterlab.abac.Role;
 import net.deterlab.abac.Identity;
+import net.deterlab.abac.Context;
 import net.deterlab.abac.Credential;
 import net.deterlab.abac.CredentialFactory;
@@ -17,9 +18,10 @@
  * from an rt0 file and runs a query against them.
  */
-public class XMLExample {
+public class CreateExample {
 
-    public static void writeCombinedIdentity(Identity i) throws IOException, FileNotFoundException {
-	FileOutputStream f = new FileOutputStream(new File("./example/" + 
-		    i.getName() + ".pem"));
+    public static void writeCombinedIdentity(Identity i, File dir) 
+	    throws IOException, FileNotFoundException {
+	FileOutputStream f = new FileOutputStream(
+		new File(dir,  i.getName() + ".pem"));
 
 	i.write(f);
@@ -28,4 +30,16 @@
     public static void main(String[] args) throws IOException {
 	try {
+	    /* The type of credentials to create is a binary name for a class
+	     * on the command line.  set type to that.
+	     */
+	    String type = (args.length > 0) ? args[0] : "default";
+
+	    /* A little much on the ?: but if the type came in on the command
+	     * line, make lastDir the last component of the name (.-separated).
+	     * Otherwise use "default" */
+	    String lastDir = (args.length > 0) ? 
+		type.substring(type.lastIndexOf('.')+1) : "default";
+
+	    Context ctxt = new Context();
 	    Identity acme = new Identity("Acme");
 	    Identity globotron = new Identity("Globotron");
@@ -36,29 +50,42 @@
 	    Collections.addAll(ids, acme, globotron, alice, bob);
 
+	    File dir = new File(new File("example"), lastDir);
+
+	    if ( !dir.isDirectory()) {
+		if (!dir.mkdirs()) {
+		    System.err.println("Could not create " + dir);
+		    System.exit(20);
+		}
+	    }
+
 	    for ( Identity i: ids) 
-		writeCombinedIdentity(i);
+		writeCombinedIdentity(i, dir);
+
+	    if (!type.equals("default"))
+		ctxt.setCredentialFactory(new CredentialFactory(
+			    new String[] {type}));
 
 
-	    GENICredential c = new GENICredential(
+	    Credential c = ctxt.newCredential(
 		    new Role(acme.getKeyID() + ".experiment_create"),
 		    new Role(acme.getKeyID() + ".partner.experiment_create"));
 	    c.make_cert(acme);
 	    creds.add(c);
-	    c = new GENICredential(
+	    c = ctxt.newCredential(
 		    new Role(acme.getKeyID() + ".partner"),
 		    new Role(globotron.getKeyID()));
 	    c.make_cert(acme);
 	    creds.add(c);
-	    c = new GENICredential(
+	    c = ctxt.newCredential(
 		    new Role(globotron.getKeyID() + ".experiment_create"),
 		    new Role(globotron.getKeyID() + ".admin.power_user"));
 	    c.make_cert(globotron);
 	    creds.add(c);
-	    c = new GENICredential(
+	    c = ctxt.newCredential(
 		    new Role(globotron.getKeyID() + ".admin"),
 		    new Role(alice.getKeyID()));
 	    c.make_cert(globotron);
 	    creds.add(c);
-	    c = new GENICredential(
+	    c = ctxt.newCredential(
 		    new Role(alice.getKeyID() + ".power_user"),
 		    new Role(bob.getKeyID()));
@@ -68,5 +95,5 @@
 	    int i =0;
 	    for (Credential cc: creds) {
-		cc.write("./example/e" + i + ".xml");
+		cc.write(new File(dir, "e" + i + ".cred").toString());
 		i ++;
 	    }
Index: java/build.xml
===================================================================
--- java/build.xml	(revision aaadefdebc0a912001992bfef4738f6f1fcc007c)
+++ java/build.xml	(revision 6b31de638ea19a82f4b9aaaa67d2bcfb4d3f7e88)
@@ -28,5 +28,5 @@
   <property name="read.class" value="Reader"/>
   <property name="write.class" value="Writer"/>
-  <property name="example.class" value="XMLExample"/>
+  <property name="example.class" value="CreateExample"/>
   <property name="version" value="1.4"/>
 
@@ -132,4 +132,25 @@
 	<pathelement path="${classes.dir}"/>
       </classpath>
+      <arg value="default"/>
+    </java>
+  </target>
+
+  <target name="run-create-geni" depends="compile" description="run visualizer">
+    <java classname="${example.class}" fork="true" >
+      <classpath>
+	<path refid="compile.classpath"/>
+	<pathelement path="${classes.dir}"/>
+      </classpath>
+      <arg value="net.deterlab.abac.GENICredential"/>
+    </java>
+  </target>
+
+  <target name="run-create-x509" depends="compile" description="run visualizer">
+    <java classname="${example.class}" fork="true" >
+      <classpath>
+	<path refid="compile.classpath"/>
+	<pathelement path="${classes.dir}"/>
+      </classpath>
+      <arg value="net.deterlab.abac.X509Credential"/>
     </java>
   </target>
