Changeset 8a93b41


Ignore:
Timestamp:
Mar 21, 2011 10:45:56 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:
cb6b61d
Parents:
42ca4b8
Message:

Save private keys as well.

Location:
java
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • java/GraphTest.java

    rf0ae3d8 r8a93b41  
    7878        }
    7979        Credential.writeZipFile(graph.credentials(),
    80                 new File("./testout.zip"), true);
     80                new File("./testout.zip"), true, true);
    8181    }
    8282}
  • java/net/deterlab/abac/Credential.java

    r42ca4b8 r8a93b41  
    433433
    434434    static public void writeZipFile(Collection<Credential> creds, File f,
    435             boolean allIDs)
     435            boolean allIDs, boolean withPrivateKeys)
    436436            throws IOException {
    437437        ZipOutputStream z = new ZipOutputStream(new FileOutputStream(f));
     
    449449            z.putNextEntry(new ZipEntry(i.getName() + ".pem"));
    450450            i.write(z);
     451            if (withPrivateKeys)
     452                i.writePrivateKey(z);
    451453            z.closeEntry();
    452454        }
  • java/net/deterlab/abac/Identity.java

    r42ca4b8 r8a93b41  
    135135        }
    136136
     137    /**
     138     * Write the PEM key to the given writer.
     139     */
     140    public boolean writePrivateKey(Writer w) throws IOException {
     141        if (kp != null ) {
     142            PEMWriter pw = new PEMWriter(w);
     143
     144            pw.writeObject(kp.getPrivate());
     145            pw.flush();
     146            return true;
     147        }
     148        else return false;
     149    }
     150
     151    /**
     152     * Write the PEM key to a file with the given name.
     153     */
     154    public boolean writePrivateKey(String fn)
     155            throws IOException, FileNotFoundException {
     156        return writePrivateKey(new FileWriter(fn));
     157    }
     158
     159    /**
     160     * Write the PEM key to the given file.
     161     */
     162    public boolean writePrivateKey(File fn)
     163            throws IOException, FileNotFoundException {
     164        return writePrivateKey(new FileWriter(fn));
     165    }
     166
     167    /**
     168     * Write the PEM key to the given OutputStream.
     169     */
     170    public boolean writePrivateKey(OutputStream s)
     171            throws IOException, FileNotFoundException {
     172        return writePrivateKey(new OutputStreamWriter(s));
     173    }
     174
    137175
    138176    /**
Note: See TracChangeset for help on using the changeset viewer.