source: java/Reader.java @ 7f16578

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

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            System.err.println("Trying " + args[i]);
32
33            try {
34                if (f.isDirectory()) 
35                    ctxt.load_directory(f, errs);
36                else if (f.getPath().endsWith(".pem")) 
37                    ctxt.load_id_file(f);
38                else if (f.getPath().endsWith(".der"))
39                    ctxt.load_attribute_file(f);
40                else if (f.getPath().endsWith(".xml"))
41                    ctxt.load_attribute_file(f);
42                else if (f.getPath().endsWith(".zip"))
43                    ctxt.load_zip(f, errs);
44                else if (f.getPath().endsWith(".rt0"))
45                    ctxt.load_rt0(f);
46                else
47                    System.out.println(f + " of unknown type");
48            }
49            catch (Exception e) {
50                System.err.println("Failed to process " + f + ": " +e);
51            }
52        }
53
54        for (String f: errs.keySet()) System.err.println(f + " " + errs.get(f));
55
56        //
57        // run the query
58        //
59
60        System.out.println("Creds");
61        for (Credential c : ctxt.credentials()) {
62            System.out.println(c.simpleString(ctxt));
63        }
64
65    }
66}
Note: See TracBrowser for help on using the repository browser.