Changeset 1a80501


Ignore:
Timestamp:
Mar 25, 2011 9:06:12 AM (8 years ago)
Author:
Ted Faber <faber@…>
Branches:
abac0-leak, abac0-mei, compt_changes, gec13, master, mei-id, mei-rt0-n, mei_rt0, mei_rt2, mei_rt2_fix_1, meiyap-rt1, meiyap1, rt2, tvf-new-xml
Children:
f25a7ff
Parents:
53f5c27
Message:

Fix query and concise credential and identity loading.

Location:
java
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • java/GraphTest.java

    r0595372 r1a80501  
    5555        Role role = new Role(args[args.length-2], ctxt);
    5656        Role prin = new Role(args[args.length-1], ctxt);
    57         Collection<Credential> ret = ctxt.query(role.toString(), prin.toString());
     57        Context.QueryResult ret = ctxt.query(role.toString(), prin.toString());
    5858        Set<Identity> ids = new TreeSet<Identity>();
    5959
     
    6161        int n = 0;
    6262        String suf = ".der";
    63         for (Credential c : ret) {
     63        System.out.println("Result: " + ret.getSuccess());
     64        for (Credential c : ret.getCredentials()) {
    6465            System.out.println(c.simpleString(ctxt));
    6566            if ( c.hasCertificate()) {
  • java/net/deterlab/abac/Context.java

    r53f5c27 r1a80501  
    3939    protected Map<String, String> nicknames;
    4040    protected Map<String, String> keys;
     41
     42    public class QueryResult {
     43        protected Collection<Credential> creds;
     44        protected boolean success;
     45
     46        public QueryResult(Collection<Credential> c, boolean s) {
     47            creds = c;
     48            success = s;
     49        }
     50
     51        public QueryResult() {
     52            creds = new TreeSet<Credential>();
     53            success = false;
     54        }
     55
     56        public Collection<Credential> getCredentials() { return creds; }
     57        public boolean getSuccess() { return success; }
     58    }
     59
    4160
    4261    public Context() {
     
    6180    }
    6281
    63     public int loadIDFile(String fn) { return loadIDFile(new File(fn)); }
    64     public int loadIDFile(File fn) {
    65         try {
    66             addIdentity(new Identity(fn));
    67         }
    68         catch (SignatureException sig) {
    69             return ABAC_CERT_BAD_SIG;
    70         }
    71         catch (Exception e) {
    72             return ABAC_CERT_INVALID;
    73         }
    74         return ABAC_CERT_SUCCESS;
    75     }
    76 
     82    public int loadIDFile(String fn) { return loadIDChunk(new File(fn)); }
     83    public int loadIDFile(File fn) { return loadIDChunk(fn); }
    7784    public int loadIDChunk(Object c) {
    7885        try {
     
    98105
    99106    public int loadAttributeFile(String fn) {
    100         return loadAttributeFile(new File(fn));
    101     }
    102 
    103     public int loadAttributeFile(File fn) {
    104         try {
    105             add_credential(new Credential(fn, identities));
    106         }
    107         catch (InvalidKeyException sig) {
    108             return ABAC_CERT_MISSING_ISSUER;
    109         }
    110         catch (Exception e) {
    111             return ABAC_CERT_INVALID;
    112         }
    113         return ABAC_CERT_SUCCESS;
    114     }
     107        return loadAttributeChunk(new File(fn));
     108    }
     109
     110    public int loadAttributeFile(File fn) { return loadAttributeChunk(fn); }
    115111
    116112    public int loadAttributeChunk(Object c) {
     
    137133    }
    138134
    139     public Collection<Credential> query(String role, String principal) {
     135    public QueryResult query(String role, String principal) {
    140136        derive_implied_edges();
    141137
    142138        Query q = new Query(g);
    143139        Graph<Role, Credential> rg = q.run(role, principal);
    144         return rg.getEdges();
     140
     141        return new QueryResult(rg.getEdges(), q.successful());
    145142    }
    146143
Note: See TracChangeset for help on using the changeset viewer.