expose the number of signed items a jar. r=mstoltz, sr=dveditz, b=179579

This commit is contained in:
dougt%netscape.com 2002-12-13 22:24:12 +00:00
parent 5c9db7b7ec
commit 32696f9ba0
4 changed files with 16 additions and 4 deletions

View File

@ -79,6 +79,8 @@ interface nsIJAR : nsISupports
* be called before getPrincipal.
*/
void getCertificatePrincipal(in string aEntryName, out nsIPrincipal aPrincipal);
readonly attribute PRUInt32 manifestEntriesCount;
};

View File

@ -151,7 +151,8 @@ DeleteManifestEntry(nsHashKey* aKey, void* aData, void* closure)
// The following initialization makes a guess of 10 entries per jarfile.
nsJAR::nsJAR(): mManifestData(nsnull, nsnull, DeleteManifestEntry, nsnull, 10),
mParsedManifest(PR_FALSE), mGlobalStatus(nsIJAR::NOT_SIGNED),
mReleaseTime(PR_INTERVAL_NO_TIMEOUT), mCache(nsnull), mLock(nsnull)
mReleaseTime(PR_INTERVAL_NO_TIMEOUT), mCache(nsnull), mLock(nsnull),
mTotalItemsInManifest(0)
{
NS_INIT_ISUPPORTS();
}
@ -407,6 +408,13 @@ nsJAR::GetCertificatePrincipal(const char* aFilename, nsIPrincipal** aPrincipal)
return NS_OK;
}
NS_IMETHODIMP
nsJAR::GetManifestEntriesCount(PRUint32* count)
{
*count = mTotalItemsInManifest;
return NS_OK;
}
//----------------------------------------------
// nsJAR private implementation
//----------------------------------------------
@ -565,13 +573,13 @@ nsJAR::ParseManifest(nsISignatureVerifier* verifier)
mParsedManifest = PR_TRUE;
return NS_OK;
}
//-- Verify that the signature file is a valid signature of the SF file
PRInt32 verifyError;
rv = verifier->VerifySignature(sigBuffer, sigLen, manifestBuffer, manifestLen,
&verifyError, getter_AddRefs(mPrincipal));
if (NS_FAILED(rv)) return rv;
if (mPrincipal)
if (mPrincipal && verifyError == 0)
mGlobalStatus = nsIJAR::VALID;
else if (verifyError == nsISignatureVerifier::VERIFY_ERROR_UNKNOWN_CA)
mGlobalStatus = nsIJAR::INVALID_UNKNOWN_CA;
@ -629,6 +637,7 @@ nsJAR::ParseOneFile(nsISignatureVerifier* verifier,
{
if (aFileType == JAR_MF)
{
mTotalItemsInManifest++;
if (curItemMF->mType != JAR_INVALID)
{
//-- Did this section have a name: line?

View File

@ -116,7 +116,7 @@ class nsJAR : public nsIZipReader, public nsIJAR
PRIntervalTime mReleaseTime; // used by nsZipReaderCache for flushing entries
nsZipReaderCache* mCache; // if cached, this points to the cache it's contained in
PRLock* mLock;
PRInt32 mTotalItemsInManifest;
//-- Private functions
nsresult ParseManifest(nsISignatureVerifier* verifier);
void ReportError(const char* aFilename, PRInt16 errorCode);

View File

@ -31,6 +31,7 @@ MODULES_LIBJAR_LCPPSRCS = \
MODULES_LIBJAR_LEXPORTS = \
zipfile.h \
zipstub.h \
zipstruct.h \
$(NULL)
MODULES_LIBJAR_LXPIDLSRCS = \