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


Java JarEntry.getCertificates方法代码示例

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


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

示例1: loadCertificates

import java.util.jar.JarEntry; //导入方法依赖的package包/类
private static Certificate[] loadCertificates(JarFile jarFile, JarEntry jarEntry) {
    InputStream is;
    try {
        // We must read the stream for the JarEntry to retrieve its certificates
        is = jarFile.getInputStream(jarEntry);
        readFullyIgnoringContents(is);

        return jarEntry.getCertificates();
    } catch (IOException | RuntimeException e) {
        System.err.println("Failed reading " + jarEntry.getName() + " in " + jarFile);

        if (DEBUG) e.printStackTrace();
        System.exit(1);
    }
    return null;
}
 
开发者ID:Fulmics,项目名称:GetApkSignInfo,代码行数:17,代码来源:Main.java

示例2: getNbmCertificates

import java.util.jar.JarEntry; //导入方法依赖的package包/类
public static Collection<Certificate> getNbmCertificates (File nbmFile) throws IOException {
    Set<Certificate> certs = new HashSet<Certificate>();
    JarFile jf = new JarFile(nbmFile);
    boolean empty = true;
    try {
        for (JarEntry entry : Collections.list(jf.entries())) {
            verifyEntry(jf, entry);
            if (!entry.getName().startsWith("META-INF/")) {
                empty = false;
                if (entry.getCertificates() != null) {
                    certs.addAll(Arrays.asList(entry.getCertificates()));
                }
            }
        }
    } finally {
        jf.close();
    }

    return empty ? null : certs;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:Utilities.java

示例3: getAndVerifyEntry

import java.util.jar.JarEntry; //导入方法依赖的package包/类
private static JarEntry getAndVerifyEntry(JarFile jar, String name, PublicKey key) throws IOException, GeneralSecurityException {
    JarEntry entry = jar.getJarEntry(name);
    if(entry == null) {
        return null;
    } else {
        byte[] buffer = new byte[1024];
        InputStream certificates = jar.getInputStream(entry);
        Throwable lastException = null;

        try {
            while(true) {
                if(certificates.read(buffer) > 0) {
                    break;
                }
            }
        } catch (Throwable var20) {
            lastException = var20;
            throw var20;
        } finally {
            if(certificates != null) {
                if(lastException != null) {
                    try {
                        certificates.close();
                    } catch (Throwable var18) {
                        lastException.addSuppressed(var18);
                    }
                } else {
                    certificates.close();
                }
            }

        }

        Certificate[] var22 = entry.getCertificates();
        if(var22 != null && var22.length != 0) {
            GeneralSecurityException var23 = null;
            boolean verified = false;
            Certificate[] var8 = var22;
            int var9 = var22.length;
            int var10 = 0;

            while(var10 < var9) {
                Certificate certificate = var8[var10];

                try {
                    certificate.verify(key);
                    verified = true;
                    break;
                } catch (GeneralSecurityException var19) {
                    var23 = var19;
                    ++var10;
                }
            }

            if(!verified) {
                throw var23;
            } else {
                return entry;
            }
        } else {
            throw new GeneralSecurityException(String.format("JAR \'%s\' is unsigned!", new Object[]{jar.getName()}));
        }
    }
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:65,代码来源:JarVerifier.java

示例4: verifyPatchMetaSignature

import java.util.jar.JarEntry; //导入方法依赖的package包/类
public boolean verifyPatchMetaSignature(File path) {
    Exception e;
    Throwable th;
    if (path == null || !path.isFile() || !path.exists() || path.length() == 0) {
        return false;
    }
    JarFile jarFile = null;
    try {
        JarFile jarFile2 = new JarFile(path);
        try {
            Enumeration<JarEntry> entries = jarFile2.entries();
            while (entries.hasMoreElements()) {
                JarEntry jarEntry = (JarEntry) entries.nextElement();
                if (jarEntry != null) {
                    String name = jarEntry.getName();
                    if (!name.startsWith("META-INF/") && name.endsWith(ShareConstants
                            .META_SUFFIX)) {
                        this.metaContentMap.put(name, SharePatchFileUtil.loadDigestes
                                (jarFile2, jarEntry));
                        Certificate[] certs = jarEntry.getCertificates();
                        if (certs == null) {
                            if (jarFile2 == null) {
                                return false;
                            }
                            try {
                                jarFile2.close();
                                return false;
                            } catch (IOException e2) {
                                Log.e(TAG, path.getAbsolutePath(), e2);
                                return false;
                            }
                        } else if (!check(path, certs)) {
                            if (jarFile2 == null) {
                                return false;
                            }
                            try {
                                jarFile2.close();
                                return false;
                            } catch (IOException e22) {
                                Log.e(TAG, path.getAbsolutePath(), e22);
                                return false;
                            }
                        }
                    }
                }
            }
            if (jarFile2 != null) {
                try {
                    jarFile2.close();
                } catch (IOException e222) {
                    Log.e(TAG, path.getAbsolutePath(), e222);
                }
            }
            return true;
        } catch (Exception e3) {
            e = e3;
            jarFile = jarFile2;
        } catch (Throwable th2) {
            th = th2;
            jarFile = jarFile2;
        }
    } catch (Exception e4) {
        e = e4;
        try {
            throw new TinkerRuntimeException(String.format("ShareSecurityCheck file %s, size " +
                    "%d verifyPatchMetaSignature fail", new Object[]{path.getAbsolutePath(),
                    Long.valueOf(path.length())}), e);
        } catch (Throwable th3) {
            th = th3;
            if (jarFile != null) {
                try {
                    jarFile.close();
                } catch (IOException e2222) {
                    Log.e(TAG, path.getAbsolutePath(), e2222);
                }
            }
            throw th;
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:81,代码来源:ShareSecurityCheck.java

示例5: getCertificates

import java.util.jar.JarEntry; //导入方法依赖的package包/类
/**
 * Return the Certificate object for this connection if the URL
 * for it points to a JAR file entry, null otherwise. This method
 * can only be called once
 * the connection has been completely verified by reading
 * from the input stream until the end of the stream has been
 * reached. Otherwise, this method will return {@code null}
 *
 * @return the Certificate object for this connection if the URL
 * for it points to a JAR file entry, null otherwise.
 *
 * @exception IOException if getting the JAR entry causes an
 * IOException to be thrown.
 *
 * @see #getJarEntry
 */
public java.security.cert.Certificate[] getCertificates()
     throws IOException
{
    JarEntry e = getJarEntry();
    return e != null ? e.getCertificates() : null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:JarURLConnection.java


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