Example usage for java.util.jar Manifest getEntries

List of usage examples for java.util.jar Manifest getEntries

Introduction

In this page you can find the example usage for java.util.jar Manifest getEntries.

Prototype

public Map<String, Attributes> getEntries() 

Source Link

Document

Returns a Map of the entries contained in this Manifest.

Usage

From source file:pxb.android.tinysign.TinySign.java

private static void doFile(String name, File f, ZipOutputStream zos, DigestOutputStream dos, Manifest m)
        throws IOException {
    zos.putNextEntry(new ZipEntry(name));
    FileInputStream fis = FileUtils.openInputStream(f);
    IOUtils.copy(fis, dos);/*from w  ww  .  j av a2s  . c  om*/
    IOUtils.closeQuietly(fis);
    byte[] digets = dos.getMessageDigest().digest();
    zos.closeEntry();
    Attributes attr = new Attributes();
    attr.putValue("SHA1-Digest", eBase64(digets));
    m.getEntries().put(name, attr);
}

From source file:pxb.android.tinysign.TinySign.java

private static Manifest generateSF(Manifest manifest)
        throws NoSuchAlgorithmException, UnsupportedEncodingException {
    MessageDigest md = MessageDigest.getInstance("SHA1");
    PrintStream print = new PrintStream(new DigestOutputStream(new OutputStream() {

        @Override//from   w w w  . j ava 2 s. c om
        public void write(byte[] arg0) throws IOException {
        }

        @Override
        public void write(byte[] arg0, int arg1, int arg2) throws IOException {
        }

        @Override
        public void write(int arg0) throws IOException {
        }
    }, md), true, "UTF-8");
    Manifest sf = new Manifest();
    Map<String, Attributes> entries = manifest.getEntries();
    for (Map.Entry<String, Attributes> entry : entries.entrySet()) {
        // Digest of the manifest stanza for this entry.
        print.print("Name: " + entry.getKey() + "\r\n");
        for (Map.Entry<Object, Object> att : entry.getValue().entrySet()) {
            print.print(att.getKey() + ": " + att.getValue() + "\r\n");
        }
        print.print("\r\n");
        print.flush();

        Attributes sfAttr = new Attributes();
        sfAttr.putValue("SHA1-Digest", eBase64(md.digest()));
        sf.getEntries().put(entry.getKey(), sfAttr);
    }
    return sf;
}