/// <summary> /// called to let us know we have processed all the /// META-INF entries, and if we re-read one of them, don't /// re-process it. Also gets rid of any data structures /// we needed when parsing META-INF entries. /// </summary> internal virtual void DoneWithMeta() { ParsingMeta = false; AnyToVerify = !SigFileSigners.Empty; Baos = null; SigFileData = null; PendingBlocks = null; SignerCache = null; ManDig = null; // MANIFEST.MF is always treated as signed and verified, // move its signers from sigFileSigners to verifiedSigners. if (SigFileSigners.ContainsKey(JarFile.MANIFEST_NAME)) { CodeSigner[] codeSigners = SigFileSigners.Remove(JarFile.MANIFEST_NAME); VerifiedSigners.Put(JarFile.MANIFEST_NAME, codeSigners); } }
/// <summary> /// called when we reach the end of entry in one of the read() methods. /// </summary> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: private void processEntry(sun.security.util.ManifestEntryVerifier mev) throws IOException private void ProcessEntry(ManifestEntryVerifier mev) { if (!ParsingBlockOrSF) { JarEntry je = mev.Entry; if ((je != null) && (je.Signers == null)) { je.Signers = mev.verify(VerifiedSigners, SigFileSigners); je.Certs = MapSignersToCertArray(je.Signers); } } else { try { ParsingBlockOrSF = false; if (Debug != null) { Debug.println("processEntry: processing block"); } String uname = mev.Entry.Name.ToUpperCase(Locale.ENGLISH); if (uname.EndsWith(".SF")) { String key = uname.Substring(0, uname.Length() - 3); sbyte[] bytes = Baos.ToByteArray(); // add to sigFileData in case future blocks need it SigFileData.Put(key, bytes); // check pending blocks, we can now process // anyone waiting for this .SF file Iterator <SignatureFileVerifier> it = PendingBlocks.Iterator(); while (it.HasNext()) { SignatureFileVerifier sfv = it.Next(); if (sfv.needSignatureFile(key)) { if (Debug != null) { Debug.println("processEntry: processing pending block"); } sfv.SignatureFile = bytes; sfv.process(SigFileSigners, ManifestDigests_Renamed); } } return; } // now we are parsing a signature block file String key = uname.Substring(0, uname.LastIndexOf(".")); if (SignerCache == null) { SignerCache = new List <>(); } if (ManDig == null) { lock (ManifestRawBytes) { if (ManDig == null) { ManDig = new ManifestDigester(ManifestRawBytes); ManifestRawBytes = null; } } } SignatureFileVerifier sfv = new SignatureFileVerifier(SignerCache, ManDig, uname, Baos.ToByteArray()); if (sfv.needSignatureFileBytes()) { // see if we have already parsed an external .SF file sbyte[] bytes = SigFileData.Get(key); if (bytes == null) { // put this block on queue for later processing // since we don't have the .SF bytes yet // (uname, block); if (Debug != null) { Debug.println("adding pending block"); } PendingBlocks.Add(sfv); return; } else { sfv.SignatureFile = bytes; } } sfv.process(SigFileSigners, ManifestDigests_Renamed); } catch (IOException ioe) { // e.g. sun.security.pkcs.ParsingException if (Debug != null) { Debug.println("processEntry caught: " + ioe); } // ignore and treat as unsigned } catch (SignatureException se) { if (Debug != null) { Debug.println("processEntry caught: " + se); } // ignore and treat as unsigned } catch (NoSuchAlgorithmException nsae) { if (Debug != null) { Debug.println("processEntry caught: " + nsae); } // ignore and treat as unsigned } catch (CertificateException ce) { if (Debug != null) { Debug.println("processEntry caught: " + ce); } // ignore and treat as unsigned } } }