import java.io.*; import java.util.*; import edu.uci.ics.jung.graph.*; import net.deterlab.abac.CredentialFactory; import net.deterlab.abac.Credential; import net.deterlab.abac.Context; import net.deterlab.abac.Role; import net.deterlab.abac.Identity; import java.security.KeyPair; /** * Simple test of the native Java implementation of ABAC. Loads credentials * from an rt0 file and runs a query against them. */ public class Reader { public static void main(String[] args) throws IOException { if (args.length < 1) { System.out.println("Usage: Reader "); System.out.println(" Reads the files and prints the credentials"); System.exit(1); } Context ctxt = new Context(); Map errs = new HashMap(); try { CredentialFactory.registerClass("net.deterlab.abac.X509Credential"); CredentialFactory.registerClass("net.deterlab.abac.GENICredential"); } catch (Exception e) { System.exit(20); } for (int i= 0; i < args.length; i++) { File f = new File(args[i]); try { if (f.isDirectory()) ctxt.load_directory(f, errs); else if (f.getPath().endsWith(".pem")) ctxt.load_id_file(f); else if (f.getPath().endsWith(".der")) ctxt.load_attribute_file(f); else if (f.getPath().endsWith(".xml")) ctxt.load_attribute_file(f); else if (f.getPath().endsWith(".zip")) ctxt.load_zip(f, errs); else if (f.getPath().endsWith(".rt0")) ctxt.load_rt0(f); else System.out.println(f + " of unknown type"); } catch (Exception e) { System.err.println("Failed to process " + f + ": " +e); } } for (String f: errs.keySet()) System.err.println(f + " " + errs.get(f)); // // run the query // System.out.println("Creds"); for (Credential c : ctxt.credentials()) { System.out.println(c.simpleString(ctxt)); System.out.println(c); } } }