source: java/Reader.java @ 7b33c9b

abac0-leakabac0-meimei-idmei-rt0-nmei_rt0tvf-new-xml
Last change on this file since 7b33c9b was 797bebe, checked in by Ted Faber <faber@…>, 11 years ago

Add Writer & checkpoint

  • Property mode set to 100644
File size: 1.7 KB
Line 
1import java.io.*;
2import java.util.*;
3
4import edu.uci.ics.jung.graph.*;
5
6import net.deterlab.abac.Credential;
7import net.deterlab.abac.Context;
8import net.deterlab.abac.Role;
9import net.deterlab.abac.Identity;
10
11import java.security.KeyPair;
12
13
14/**
15 * Simple test of the native Java implementation of ABAC. Loads credentials
16 * from an rt0 file and runs a query against them.
17 */
18public class Reader {
19    public static void main(String[] args) throws IOException {
20        if (args.length < 1) {
21            System.out.println("Usage: Reader <files>");
22            System.out.println("   Reads the files and prints the credentials");
23            System.exit(1);
24        }
25
26        Context ctxt = new Context();
27        Map<String, Exception> errs = new HashMap<String, Exception>();
28
29        for (int i= 0; i < args.length; i++) {
30            File f = new File(args[i]);
31
32            try {
33                if (f.isDirectory()) 
34                    ctxt.load_directory(f, errs);
35                else if (f.getPath().endsWith(".pem")) 
36                    ctxt.load_id_file(f);
37                else if (f.getPath().endsWith(".der"))
38                    ctxt.load_attribute_file(f);
39                else if (f.getPath().endsWith(".xml"))
40                    ctxt.load_attribute_file(f);
41                else if (f.getPath().endsWith(".zip"))
42                    ctxt.load_zip(f, errs);
43                else if (f.getPath().endsWith(".rt0"))
44                    ctxt.load_rt0(f);
45                else
46                    System.out.println(f + " of unknown type");
47            }
48            catch (Exception e) {
49                System.err.println("Failed to process " + f + ": " +e);
50            }
51        }
52
53        for (String f: errs.keySet()) System.err.println(f + " " + errs.get(f));
54
55        //
56        // run the query
57        //
58
59        System.out.println("Creds");
60        for (Credential c : ctxt.credentials()) {
61            System.out.println(c.simpleString(ctxt));
62            System.out.println(c);
63        }
64
65    }
66}
Note: See TracBrowser for help on using the repository browser.