import java.io.*; import edu.uci.ics.jung.graph.*; import net.deterlab.abac.Credential; import net.deterlab.abac.CredentialGraph; import net.deterlab.abac.Query; import net.deterlab.abac.Role; /** * Simple test of the native Java implementation of ABAC. Loads credentials * from an rt0 file and runs a query against them. */ public class GraphTest { public static void main(String[] args) throws IOException { if (args.length < 3) { System.out.println("Usage: GraphTest "); System.out.println(" runs the query role <-?- principal and prints the result"); System.exit(1); } String role = args[1]; String prin = args[2]; CredentialGraph graph = new CredentialGraph(); BufferedReader reader = new BufferedReader(new FileReader(args[0])); String line; while ((line = reader.readLine()) != null) { // skip comments if (line.startsWith("#")) continue; String[] parts = line.split("\\s*<--?\\s*"); if (parts.length != 2) { System.out.println("Warning: funky line: " + line); continue; } Role head = new Role(parts[0]); Role tail = new Role(parts[1]); if (!head.is_role()) { System.out.println("Warning: invalid role in head position: " + line); continue; } Credential cred = new Credential(head, tail); graph.add_credential(cred); } // // run the query // Query q = graph.querier(); Graph ret = q.run(role, prin); for (Credential c : ret.getEdges()) System.out.println(c.toString()); } }