当前位置: 首页>>代码示例>>Java>>正文


Java Manifest.getEntries方法代码示例

本文整理汇总了Java中java.util.jar.Manifest.getEntries方法的典型用法代码示例。如果您正苦于以下问题:Java Manifest.getEntries方法的具体用法?Java Manifest.getEntries怎么用?Java Manifest.getEntries使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.jar.Manifest的用法示例。


在下文中一共展示了Manifest.getEntries方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: copyFiles

import java.util.jar.Manifest; //导入方法依赖的package包/类
/**
 * Copy all the files in a manifest from input to output.  We set
 * the modification times in the output to a fixed time, so as to
 * reduce variation in the output file and make incremental OTAs
 * more efficient.
 */
private void copyFiles(Manifest manifest, Map<String,ZioEntry> input, ZipOutput output, long timestamp)
    throws IOException 
{
    Map<String, Attributes> entries = manifest.getEntries();
    List<String> names = new ArrayList<String>(entries.keySet());
    Collections.sort(names);
    int i = 1;
    for (String name : names) {
        if (canceled) break;
        progressHelper.progress(ProgressEvent.PRORITY_NORMAL, resourceAdapter.getString(ResourceAdapter.Item.COPYING_ZIP_ENTRY, i, names.size()));
        i += 1;
        ZioEntry inEntry = input.get(name);
        inEntry.setTime(timestamp);
        output.write(inEntry);

    }
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:24,代码来源:ZipSigner.java

示例2: copyFiles

import java.util.jar.Manifest; //导入方法依赖的package包/类
/**
 * Copy all the files in a manifest from input to output.  We set
 * the modification times in the output to a fixed time, so as to
 * reduce variation in the output file and make incremental OTAs
 * more efficient.
 */
private void copyFiles(Manifest manifest, Map<String, ZioEntry> input, ZipOutput output, long timestamp)
        throws IOException {
    Map<String, Attributes> entries = manifest.getEntries();
    List<String> names = new ArrayList<String>(entries.keySet());
    Collections.sort(names);
    int i = 1;
    for (String name : names) {
        if (canceled) break;
        progressHelper.progress(ProgressEvent.PRORITY_NORMAL, resourceAdapter.getString(ResourceAdapter.Item.COPYING_ZIP_ENTRY, i, names.size()));
        i += 1;
        ZioEntry inEntry = input.get(name);
        inEntry.setTime(timestamp);
        output.write(inEntry);

    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:23,代码来源:ZipSigner.java

示例3: get2thDexSHA1

import java.util.jar.Manifest; //导入方法依赖的package包/类
/**
 * 获取dex2文件的SHA1-Digest值
 *
 * @param context
 * @return
 */
private String get2thDexSHA1(Context context) {
    ApplicationInfo info = context.getApplicationInfo();
    String source = info.sourceDir;
    try {
        JarFile jar = new JarFile(source);
        Manifest mf = jar.getManifest();
        Map<String, Attributes> map = mf.getEntries();
        Attributes a = map.get("classes2.dex");
        return a.getValue("SHA1-Digest");
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
 
开发者ID:ymqq,项目名称:CommonFramework,代码行数:21,代码来源:BaseApplication.java

示例4: generateSignatureFile

import java.util.jar.Manifest; //导入方法依赖的package包/类
/** Write the signature file to the given output stream. */
private void generateSignatureFile(Manifest manifest, OutputStream out)
throws IOException, GeneralSecurityException {
    out.write( ("Signature-Version: 1.0\r\n").getBytes());
    out.write( ("Created-By: 1.0 (Android SignApk)\r\n").getBytes());


    // BASE64Encoder base64 = new BASE64Encoder();
    MessageDigest md = MessageDigest.getInstance("SHA1");
    PrintStream print = new PrintStream(
            new DigestOutputStream(new ByteArrayOutputStream(), md),
            true, "UTF-8");

    // Digest of the entire manifest
    manifest.write(print);
    print.flush();

    out.write( ("SHA1-Digest-Manifest: "+ Base64.encode(md.digest()) + "\r\n\r\n").getBytes());

    Map<String, Attributes> entries = manifest.getEntries();
    for (Map.Entry<String, Attributes> entry : entries.entrySet()) {
        if (canceled) break;
        progressHelper.progress( ProgressEvent.PRORITY_NORMAL, resourceAdapter.getString(ResourceAdapter.Item.GENERATING_SIGNATURE_FILE));
        // Digest of the manifest stanza for this entry.
        String nameEntry = "Name: " + entry.getKey() + "\r\n"; 
        print.print( nameEntry);
        for (Map.Entry<Object, Object> att : entry.getValue().entrySet()) {
            print.print(att.getKey() + ": " + att.getValue() + "\r\n");
        }
        print.print("\r\n");
        print.flush();

        out.write( nameEntry.getBytes());
        out.write( ("SHA1-Digest: " +  Base64.encode(md.digest()) + "\r\n\r\n").getBytes());
    }

}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:38,代码来源:ZipSigner.java

示例5: generateSignatureFile

import java.util.jar.Manifest; //导入方法依赖的package包/类
/**
 * Write the signature file to the given output stream.
 */
private void generateSignatureFile(Manifest manifest, OutputStream out)
        throws IOException, GeneralSecurityException {
    out.write(("Signature-Version: 1.0\r\n").getBytes());
    out.write(("Created-By: 1.0 (Android SignApk)\r\n").getBytes());


    // BASE64Encoder base64 = new BASE64Encoder();
    MessageDigest md = MessageDigest.getInstance("SHA1");
    PrintStream print = new PrintStream(
            new DigestOutputStream(new ByteArrayOutputStream(), md),
            true, "UTF-8");

    // Digest of the entire manifest
    manifest.write(print);
    print.flush();

    out.write(("SHA1-Digest-Manifest: " + Base64.encode(md.digest()) + "\r\n\r\n").getBytes());

    Map<String, Attributes> entries = manifest.getEntries();
    for (Map.Entry<String, Attributes> entry : entries.entrySet()) {
        if (canceled) break;
        progressHelper.progress(ProgressEvent.PRORITY_NORMAL, resourceAdapter.getString(ResourceAdapter.Item.GENERATING_SIGNATURE_FILE));
        // Digest of the manifest stanza for this entry.
        String nameEntry = "Name: " + entry.getKey() + "\r\n";
        print.print(nameEntry);
        for (Map.Entry<Object, Object> att : entry.getValue().entrySet()) {
            print.print(att.getKey() + ": " + att.getValue() + "\r\n");
        }
        print.print("\r\n");
        print.flush();

        out.write(nameEntry.getBytes());
        out.write(("SHA1-Digest: " + Base64.encode(md.digest()) + "\r\n\r\n").getBytes());
    }

}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:40,代码来源:ZipSigner.java

示例6: outputToJar

import java.util.jar.Manifest; //导入方法依赖的package包/类
/**
 * Generate output JAR-file and packages
 */
public void outputToJar() throws IOException {
    // create the manifest
    final Manifest manifest = new Manifest();
    final java.util.jar.Attributes atrs = manifest.getMainAttributes();
    atrs.put(java.util.jar.Attributes.Name.MANIFEST_VERSION, "1.2");

    final Map<String, Attributes> map = manifest.getEntries();
    // create manifest
    final String now = (new Date()).toString();
    final java.util.jar.Attributes.Name dateAttr =
        new java.util.jar.Attributes.Name("Date");

    final File jarFile = new File(_destDir, _jarFileName);
    final JarOutputStream jos =
        new JarOutputStream(new FileOutputStream(jarFile), manifest);

    for (JavaClass clazz : _bcelClasses) {
        final String className = clazz.getClassName().replace('.', '/');
        final java.util.jar.Attributes attr = new java.util.jar.Attributes();
        attr.put(dateAttr, now);
        map.put(className + ".class", attr);
        jos.putNextEntry(new JarEntry(className + ".class"));
        final ByteArrayOutputStream out = new ByteArrayOutputStream(2048);
        clazz.dump(out); // dump() closes it's output stream
        out.writeTo(jos);
    }
    jos.close();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:XSLTC.java

示例7: signatureFile

import java.util.jar.Manifest; //导入方法依赖的package包/类
/** Write a .SF file with a digest of the specified manifest. */
private static void signatureFile(Manifest manifest, SignatureStream out)
        throws IOException, GeneralSecurityException {
    Manifest sf = new Manifest();
    Attributes main = sf.getMainAttributes();
    main.putValue("Signature-Version", "1.0");
    
    BASE64Encoder base64 = new BASE64Encoder();
    MessageDigest md = MessageDigest.getInstance("SHA1");
    PrintStream print = new PrintStream(
            new DigestOutputStream(new ByteArrayOutputStream(), md), true, "UTF-8");

    // Digest of the entire manifest
    manifest.write(print);
    print.flush();
    main.putValue("SHA1-Digest-Manifest", base64.encode(md.digest()));
    
    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", base64.encode(md.digest()));
        sf.getEntries().put(entry.getKey(), sfAttr);
    }
    
    System.out.print("\rGenerating signature file...");
    
    sf.write(out);

    // A bug in the java.util.jar implementation of Android platforms
    // up to version 1.6 will cause a spurious IOException to be thrown
    // if the length of the signature file is a multiple of 1024 bytes.
    // As a workaround, add an extra CRLF in this case.
    if ((out.size() % 1024) == 0) {
        out.write('\r');
        out.write('\n');
    }
}
 
开发者ID:KuroroLucilfer,项目名称:PackageSigner2,代码行数:45,代码来源:Signer.java


注:本文中的java.util.jar.Manifest.getEntries方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。