Changeset e1c49ce


Ignore:
Timestamp:
Mar 14, 2011 2:50:03 PM (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:
8a6181b, f797fca
Parents:
5cf72cc
Message:

Make zipfile take a file, disambiguate same name/different keys

Location:
java
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • java/GraphTest.java

    r5cf72cc re1c49ce  
    11import java.io.*;
    22import java.util.*;
    3 import java.util.zip.*;
    43
    54import edu.uci.ics.jung.graph.*;
     
    5049                    graph.add_credential(new Credential(f));
    5150                else if (f.getPath().endsWith(".zip"))
    52                     for (Credential c :Credential.readZipFile(new ZipFile(f), kp, errs))
     51                    for (Credential c :Credential.readZipFile(f, kp, errs))
    5352                        graph.add_credential(c);
    5453                else
  • java/net/deterlab/abac/Credential.java

    r5cf72cc re1c49ce  
    216216     * are added indexed by filename.
    217217     */
    218     static public Collection<Credential> readZipFile(ZipFile z,
    219             Collection<KeyPair> keys, Map<String, Exception> errors) {
     218    static public Collection<Credential> readZipFile(File zf,
     219            Collection<KeyPair> keys, Map<String, Exception> errors)
     220                throws IOException {
    220221        Vector<Credential> creds = new Vector<Credential>();
    221222        Vector<ZipEntry> derFiles = new Vector<ZipEntry>();
     223
     224        ZipFile z = new ZipFile(zf);
    222225
    223226        for (Enumeration<? extends ZipEntry> ze = z.entries();
     
    267270    }
    268271
    269     static public Collection<Credential> readZipFile(ZipFile d) {
     272    static public Collection<Credential> readZipFile(File d)
     273            throws IOException {
    270274        return readZipFile(d, null, null);
    271275    }
    272     static public Collection<Credential> readZipFile(ZipFile d,
    273             Map<String, Exception> errors) {
     276    static public Collection<Credential> readZipFile(File d,
     277            Map<String, Exception> errors) throws IOException {
    274278        return readZipFile(d, null, errors);
    275279    }
    276     static public Collection<Credential> readZipFile(ZipFile d,
    277             Collection<KeyPair> keys) {
     280    static public Collection<Credential> readZipFile(File d,
     281            Collection<KeyPair> keys) throws IOException {
    278282        return readZipFile(d, keys, null);
    279283    }
     
    291295        Vector<Credential> creds = new Vector<Credential>();
    292296        Vector<File> derFiles = new Vector<File>();
    293 
    294         for (File f: d.listFiles() ) {
     297        Collection<File> files = new Vector<File>();
     298
     299        if (d.isDirectory() )
     300            for (File f : d.listFiles())
     301                files.add(f);
     302        else files.add(d);
     303
     304        System.err.println(files);
     305        for (File f: files ) {
    295306            Object o = null;
    296307            try {
     
    375386private Identity m_id;
    376387
     388    /**
     389     * Put the Identity into the set of ids used to validate certificates.
     390     * Also put the keyID and name into the translation mappings used by Roles
     391     * to pretty print.  In the role mapping, if multiple ids use the same
     392     * common name they are disambiguated.  Only one entry for keyid is
     393     * allowed.
     394     */
    377395    public static void addIdentity(Identity id) {
    378396        s_ids.add(id);
    379         if (id.getName() != null && id.getKeyID() != null)
    380             Role.add_mapping(id.getName(), id.getKeyID());
     397        if (id.getName() != null && id.getKeyID() != null) {
     398            if ( !Role.key_in_mapping(id.getKeyID()) ) {
     399                String name = id.getName();
     400                int n= 1;
     401
     402                while (Role.name_in_mapping(name)) {
     403                    name = id.getName() + n++;
     404                }
     405                Role.add_mapping(name, id.getKeyID());
     406            }
     407        }
    381408    }
    382409    public static Collection<Identity> identities() { return s_ids; }
     410    public static void clearIdentities() {
     411        s_ids.clear(); Role.clear_mapping();
     412    }
    383413}
  • java/net/deterlab/abac/Role.java

    r281158a re1c49ce  
    198198    }
    199199
     200    public static boolean key_in_mapping(String key) {
     201        return keys.containsKey(key);
     202    }
     203
     204    public static boolean name_in_mapping(String name) {
     205        return nicknames.containsKey(name);
     206    }
     207
     208    public static void clear_mapping() { nicknames.clear(); keys.clear(); }
     209
    200210}
Note: See TracChangeset for help on using the changeset viewer.