Index: java/GraphTest.java
===================================================================
--- java/GraphTest.java	(revision 7ef13e3cc81eaa60349fd3c9d82f156e48d74d19)
+++ java/GraphTest.java	(revision cae7369115c56ff9d114fe6191d20d51c3b71caa)
@@ -22,4 +22,69 @@
 public class GraphTest {
 
+    /**
+     * Tokenizer to parse files of a name and the key it binds to.
+     */
+    protected static class AliasTokenizer extends StreamTokenizer {
+	public AliasTokenizer(Reader f) {
+	    super(f);
+	    resetSyntax();
+	    wordChars('a', 'z');
+	    wordChars('A', 'Z');
+	    wordChars('0', '9');
+	    whitespaceChars(' ', ' ');
+	    whitespaceChars('\t', '\t');
+	    whitespaceChars('\n', '\n');
+	}
+    };
+
+
+    /**
+     * Read the alias file and construct 2 bindings nickname to key (nick) and
+     * key to nickname (key)
+     */
+    protected static void importAliases(File f, Map<String, String> nick,
+	    Map<String, String> key) 
+	throws FileNotFoundException, IOException {
+	AliasTokenizer at = new AliasTokenizer(new FileReader(f));
+
+	at.nextToken();
+	while (at.ttype != AliasTokenizer.TT_EOF) {
+	    String n = at.sval;
+	    if (at.nextToken() == AliasTokenizer.TT_WORD) {
+		String k = at.sval;
+
+		nick.put(n, k);
+		key.put(k, n);
+		at.nextToken();
+	    }
+	}
+    }
+
+    /**
+     * Translate either keys to nicknames or vice versa.  Break the string into
+     * space separated tokens and then each of them into period separated
+     * strings.  If any of the smallest strings is in the map, replace it with
+     * the value.
+     */
+    protected static String replace(String is, Map<String, String> m) {
+	String rv = "";
+	for (String tok: is.split(" ")) {
+	    String term = "";
+	    for (String s: tok.split("\\.")) {
+		String next = m.containsKey(s) ? m.get(s) : s;
+
+		if (term.isEmpty()) term = next;
+		else term += "." + next;
+	    }
+	    if (rv.isEmpty()) rv = term;
+	    else rv += " " + term;
+	}
+	return rv;
+    }
+
+
+    /**
+     * Import a credential from a der file and add it to the credential graph.
+     */
     protected static void importCred(File f, CredentialGraph g) 
 	throws Exception {
@@ -29,11 +94,19 @@
 
 
-    protected static void importDir(File d, CredentialGraph g) {
+    /**
+     * Import a directory full of files, using the suffixes as determinants.
+     * First import all the identities (pem), then the credentials (der) into
+     * the credential graph then any alias files into the two maps.
+     */
+    protected static void importDir(File d, CredentialGraph g, 
+	    Map<String, String> nick, Map<String, String> keys) {
 	Vector<File> ids = new Vector<File>();
 	Vector<File> creds = new Vector<File>();
+	Vector<File> alias = new Vector<File>();
 
 	for (File f: d.listFiles()) {
 	    if (f.getPath().endsWith(".pem")) ids.add(f);
 	    else if (f.getPath().endsWith(".der") ) creds.add(f);
+	    else if (f.getPath().endsWith(".alias") ) alias.add(f);
 	    else System.out.println(f + " of unknown type");
 	}
@@ -55,4 +128,12 @@
 	    }
 	}
+	for (File f: alias) {
+	    try {
+		importAliases(f, nick, keys);
+	    }
+	    catch (Exception e) {
+		System.err.println("Cannot add " + f + ": " + e);
+	    }
+	}
     }
     public static void main(String[] args) throws IOException {
@@ -64,4 +145,6 @@
 
         CredentialGraph graph = new CredentialGraph();
+	TreeMap<String, String> nicknames = new TreeMap<String, String>();
+	TreeMap<String, String> keys = new TreeMap<String, String>();
         String role = args[args.length-2];
         String prin = args[args.length-1];
@@ -72,9 +155,11 @@
 	    try {
 		if (f.isDirectory()) 
-		    importDir(f, graph);
+		    importDir(f, graph, nicknames, keys);
 		else if (f.getPath().endsWith(".pem"))
 		    Credential.addIdentity(f);
 		else if (f.getPath().endsWith(".der"))
 		    importCred(f, graph);
+		else if (f.getPath().endsWith(".alias"))
+		    importAliases(f, nicknames, keys);
 		else
 		    System.out.println(f + " of unknown type");
@@ -84,4 +169,8 @@
 	    }
 	}
+
+	// Translate nicknames into key ids.
+	role = replace(role, nicknames);
+	prin = replace(prin, nicknames);
         //
         // run the query
@@ -91,5 +180,5 @@
         Graph<Role, Credential> ret = q.run(role, prin);
         for (Credential c : ret.getEdges())
-            System.out.println(c.toString());
+            System.out.println(replace(c.toString(), keys));
     }
 }
