super(stream); if (verify) { verifier = new JarVerifier("JarInputStream"); closeEntry(); if (verify) { verifier.setManifest(manifest); if (manifest != null) { verifier.mainAttributesEnd = manifest.getMainAttributesEnd();
if (verifier != null) { if (isMeta) { verifier.addMetaEntry(jarEntry.getName(), ((ByteArrayOutputStream) verStream) .toByteArray()); try { verifier.readCertificates(); } catch (SecurityException e) { verifier = null;
return; } catch (GeneralSecurityException e) { throw failedVerification(jarName, signatureFile); if (!verify(attributes, digestAttribute, manifest, 0, mainAttributesEnd, false, true)) { throw failedVerification(jarName, signatureFile); if (!verify(attributes, digestAttribute, manifest, 0, manifest.length, false, false)) { Iterator<Map.Entry<String, Attributes>> it = entries.entrySet().iterator(); while (it.hasNext()) { return; if (!verify(entry.getValue(), "-Digest", manifest, chunk.start, chunk.end, createdBySigntool, false)) { throw invalidDigest(signatureFile, entry.getKey(), jarName);
verifier.setManifest(getManifest()); if (manifest != null) { verifier.mainAttributesEnd = manifest.getMainAttributesEnd(); if (verifier.readCertificates()) { verifier.removeMetaEntries(); if (manifest != null) { manifest.removeChunks(); if (!verifier.isSignedJar()) { verifier = null; return in; JarVerifier.VerifierEntry entry = verifier.initEntry(ze.getName()); if (entry == null) { return in;
/** * Create a new {@code JarFile} using the contents of the specified file. * * @param file * the JAR file as {@link File}. * @param verify * if this JAR file is signed whether it must be verified. * @throws IOException * If the file cannot be read. */ public JarFile(File file, boolean verify) throws IOException { super(file); if (verify) { verifier = new JarVerifier(file.getPath()); } readMetaEntries(); }
InputStream is = super.getInputStream(manifestEntry); if (verifier != null) { verifier.addMetaEntry(manifestEntry.getName(), Streams.readFully(is)); is = super.getInputStream(manifestEntry);
/** * Returns an array of {@code Certificate} Objects associated with this * entry or {@code null} if none exists. Make sure that the everything is * read from the input stream before calling this method, or else the method * returns {@code null}. * * @return the certificate for this entry. * @see java.security.cert.Certificate */ public Certificate[] getCertificates() { if (parentJar == null) { return null; } JarVerifier jarVerifier = parentJar.verifier; if (jarVerifier == null) { return null; } return jarVerifier.getCertificates(getName()); }
verStream = new ByteArrayOutputStream(); } else { verStream = verifier.initEntry(jarEntry.getName());
certs.addAll(getSignerCertificates(signatureFile, certificates));
verifier.setManifest(getManifest()); if (manifest != null) { verifier.mainAttributesEnd = manifest.getMainAttributesEnd(); if (verifier.readCertificates()) { verifier.removeMetaEntries(); if (manifest != null) { manifest.removeChunks(); if (!verifier.isSignedJar()) { verifier = null; return in; JarVerifier.VerifierEntry entry = verifier.initEntry(ze.getName()); if (entry == null) { return in;
/** * Create a new {@code JarFile} from the contents of the file specified by * {@code filename}. * * @param filename * the file name referring to the JAR file. * @param verify * if this JAR filed is signed whether it must be verified. * @throws IOException * If file cannot be opened or read. */ public JarFile(String filename, boolean verify) throws IOException { super(filename); if (verify) { verifier = new JarVerifier(filename); } readMetaEntries(); }
signed = true; InputStream is = super.getInputStream(entry); verifier.addMetaEntry(entryName, Streams.readFully(is));
/** * Returns an array of {@code Certificate} Objects associated with this * entry or {@code null} if none exists. Make sure that the everything is * read from the input stream before calling this method, or else the method * returns {@code null}. * * @return the certificate for this entry. * @see java.security.cert.Certificate */ public Certificate[] getCertificates() { if (parentJar == null) { return null; } JarVerifier jarVerifier = parentJar.verifier; if (jarVerifier == null) { return null; } return jarVerifier.getCertificates(getName()); }
verStream = new ByteArrayOutputStream(); } else { verStream = verifier.initEntry(jarEntry.getName());
certs.addAll(getSignerCertificates(signatureFile, certificates));
verifier.setManifest(getManifest()); if (manifest != null) { verifier.mainAttributesEnd = manifest.getMainAttributesEnd(); if (verifier.readCertificates()) { verifier.removeMetaEntries(); if (manifest != null) { manifest.removeChunks(); if (!verifier.isSignedJar()) { verifier = null; return in; JarVerifier.VerifierEntry entry = verifier.initEntry(ze.getName()); if (entry == null) { return in;
return; } catch (GeneralSecurityException e) { throw failedVerification(jarName, signatureFile); if (!verify(attributes, digestAttribute, manifest, 0, mainAttributesEnd, false, true)) { throw failedVerification(jarName, signatureFile); if (!verify(attributes, digestAttribute, manifest, 0, manifest.length, false, false)) { Iterator<Map.Entry<String, Attributes>> it = entries.entrySet().iterator(); while (it.hasNext()) { return; if (!verify(entry.getValue(), "-Digest", manifest, chunk.start, chunk.end, createdBySigntool, false)) { throw invalidDigest(signatureFile, entry.getKey(), jarName);
super(stream); if (verify) { verifier = new JarVerifier("JarInputStream"); closeEntry(); if (verify) { verifier.setManifest(manifest); if (manifest != null) { verifier.mainAttributesEnd = manifest.getMainAttributesEnd();
/** * Create a new {@code JarFile} using the contents of file. * * @param file * the JAR file as {@link File}. * @param verify * if this JAR filed is signed whether it must be verified. * @param mode * the mode to use, either {@link ZipFile#OPEN_READ OPEN_READ} or * {@link ZipFile#OPEN_DELETE OPEN_DELETE}. * @throws IOException * If the file cannot be read. */ public JarFile(File file, boolean verify, int mode) throws IOException { super(file, mode); if (verify) { verifier = new JarVerifier(file.getPath()); } readMetaEntries(); }
if (verifier != null) { if (isMeta) { verifier.addMetaEntry(jarEntry.getName(), ((ByteArrayOutputStream) verStream) .toByteArray()); try { verifier.readCertificates(); } catch (SecurityException e) { verifier = null;