當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。