зеркало из https://github.com/mozilla/pjs.git
Bug 346010 - Decom nsIJAR by merging it into nsIZipReader. r=tglek, sr=bsmedberg
This commit is contained in:
Родитель
3612c742f6
Коммит
cdb791bb33
|
@ -71,7 +71,6 @@
|
|||
#include "nsIFile.h"
|
||||
#include "nsIFileURL.h"
|
||||
#include "nsIZipReader.h"
|
||||
#include "nsIJAR.h"
|
||||
#include "nsIPluginInstance.h"
|
||||
#include "nsIXPConnect.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
|
@ -2871,9 +2870,7 @@ nsScriptSecurityManager::SetCanEnableCapability(const nsACString& certFingerprin
|
|||
rv = systemCertZip->Open(systemCertFile);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
nsCOMPtr<nsIJAR> systemCertJar(do_QueryInterface(systemCertZip, &rv));
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
rv = systemCertJar->GetCertificatePrincipal(nsnull,
|
||||
rv = systemCertZip->GetCertificatePrincipal(nsnull,
|
||||
getter_AddRefs(mSystemCertificate));
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
|
|
@ -1,93 +0,0 @@
|
|||
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released
|
||||
* March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Daniel Veditz <dveditz@netscape.com>
|
||||
* Don Bragg <dbragg@netscape.com>
|
||||
* Samir Gehani <sgehani@netscape.com>
|
||||
* Mitch Stoltz <mstoltz@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
%{C++
|
||||
#define NS_JAR_CID \
|
||||
{ /* 04501DB3-0409-11d3-BCF8-00805F0E1353*/ \
|
||||
0x04501DB3, \
|
||||
0x0409, \
|
||||
0x11d3, \
|
||||
{0xbc, 0xf8, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53} \
|
||||
}
|
||||
|
||||
#define NS_JAR_CONTRACTID \
|
||||
"@mozilla.org/libjar;1"
|
||||
|
||||
#define NS_IJARFactory_IID \
|
||||
{ /* 04501DB4-0409-11d3-BCF8-00805F0E1353 */ \
|
||||
0x04501DB4, \
|
||||
0x0409, \
|
||||
0x11d3, \
|
||||
{0xbc, 0xf8, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53} \
|
||||
}
|
||||
|
||||
#define NS_JARFactory_CID \
|
||||
{ /* 04501DB5-0409-11d3-BCF8-00805F0E1353 */ \
|
||||
0x04501DB5, \
|
||||
0x0409, \
|
||||
0x11d3, \
|
||||
{0xbc, 0xf8, 0x00, 0x80, 0x5f, 0x0e, 0x13, 0x53} \
|
||||
}
|
||||
%}
|
||||
|
||||
interface nsIPrincipal;
|
||||
|
||||
[scriptable, uuid(04501DB2-0409-11d3-BCF8-00805F0E1353)]
|
||||
interface nsIJAR : nsISupports
|
||||
{
|
||||
/**
|
||||
* Returns an object describing the entity which signed
|
||||
* an entry. parseManifest must be called first. If aEntryName is an
|
||||
* entry in the jar, getInputStream must be called after parseManifest.
|
||||
* If aEntryName is an external file which has meta-information
|
||||
* stored in the jar, verifyExternalFile (not yet implemented) must
|
||||
* be called before getPrincipal.
|
||||
*/
|
||||
nsIPrincipal getCertificatePrincipal(in string aEntryName);
|
||||
|
||||
readonly attribute PRUint32 manifestEntriesCount;
|
||||
|
||||
};
|
||||
|
|
@ -47,6 +47,7 @@
|
|||
interface nsIUTF8StringEnumerator;
|
||||
interface nsIInputStream;
|
||||
interface nsIFile;
|
||||
interface nsIPrincipal;
|
||||
|
||||
[scriptable, uuid(e1c028bc-c478-11da-95a8-00e08161165f)]
|
||||
interface nsIZipEntry : nsISupports
|
||||
|
@ -90,7 +91,7 @@ interface nsIZipEntry : nsISupports
|
|||
readonly attribute boolean isSynthetic;
|
||||
};
|
||||
|
||||
[scriptable, uuid(5cce7f53-23b3-47f8-be05-122c0ba703fd)]
|
||||
[scriptable, uuid(27067432-cb21-437e-99d1-f85858522bb1)]
|
||||
interface nsIZipReader : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -198,6 +199,18 @@ interface nsIZipReader : nsISupports
|
|||
* @param zipEntry the name of the entry to open the stream from
|
||||
*/
|
||||
nsIInputStream getInputStreamWithSpec(in AUTF8String aJarSpec, in string zipEntry);
|
||||
|
||||
/**
|
||||
* Returns an object describing the entity which signed
|
||||
* an entry. parseManifest must be called first. If aEntryName is an
|
||||
* entry in the jar, getInputStream must be called after parseManifest.
|
||||
* If aEntryName is an external file which has meta-information
|
||||
* stored in the jar, verifyExternalFile (not yet implemented) must
|
||||
* be called before getPrincipal.
|
||||
*/
|
||||
nsIPrincipal getCertificatePrincipal(in string aEntryName);
|
||||
|
||||
readonly attribute PRUint32 manifestEntriesCount;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -131,7 +131,7 @@ nsJAR::~nsJAR()
|
|||
Close();
|
||||
}
|
||||
|
||||
NS_IMPL_THREADSAFE_QUERY_INTERFACE2(nsJAR, nsIZipReader, nsIJAR)
|
||||
NS_IMPL_THREADSAFE_QUERY_INTERFACE1(nsJAR, nsIZipReader)
|
||||
NS_IMPL_THREADSAFE_ADDREF(nsJAR)
|
||||
|
||||
// Custom Release method works with nsZipReaderCache...
|
||||
|
@ -336,10 +336,6 @@ nsJAR::GetInputStreamWithSpec(const nsACString& aJarDirSpec,
|
|||
return rv;
|
||||
}
|
||||
|
||||
//----------------------------------------------
|
||||
// nsIJAR implementation
|
||||
//----------------------------------------------
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJAR::GetCertificatePrincipal(const char* aFilename, nsIPrincipal** aPrincipal)
|
||||
{
|
||||
|
@ -1063,7 +1059,7 @@ nsZipReaderCache::GetZip(nsIFile* zipFile, nsIZipReader* *result)
|
|||
{
|
||||
NS_ENSURE_ARG_POINTER(zipFile);
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIJAR> antiLockZipGrip;
|
||||
nsCOMPtr<nsIZipReader> antiLockZipGrip;
|
||||
nsAutoLock lock(mLock);
|
||||
|
||||
#ifdef ZIP_CACHE_HIT_RATE
|
||||
|
|
|
@ -60,7 +60,6 @@
|
|||
#include "nsHashtable.h"
|
||||
#include "nsAutoLock.h"
|
||||
#include "nsIZipReader.h"
|
||||
#include "nsIJAR.h"
|
||||
#include "nsZipArchive.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsISignatureVerifier.h"
|
||||
|
@ -90,7 +89,7 @@ typedef enum
|
|||
* nsJAR serves as an XPCOM wrapper for nsZipArchive with the addition of
|
||||
* JAR manifest file parsing.
|
||||
*------------------------------------------------------------------------*/
|
||||
class nsJAR : public nsIZipReader, public nsIJAR
|
||||
class nsJAR : public nsIZipReader
|
||||
{
|
||||
// Allows nsJARInputStream to call the verification functions
|
||||
friend class nsJARInputStream;
|
||||
|
@ -106,8 +105,6 @@ class nsJAR : public nsIZipReader, public nsIJAR
|
|||
|
||||
NS_DECL_NSIZIPREADER
|
||||
|
||||
NS_DECL_NSIJAR
|
||||
|
||||
nsresult GetJarPath(nsACString& aResult);
|
||||
|
||||
PRIntervalTime GetReleaseTime() {
|
||||
|
|
|
@ -52,7 +52,6 @@
|
|||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsIFileURL.h"
|
||||
#include "nsIJAR.h"
|
||||
|
||||
static NS_DEFINE_CID(kZipReaderCID, NS_ZIPREADER_CID);
|
||||
|
||||
|
@ -497,14 +496,8 @@ nsJARChannel::GetOwner(nsISupports **result)
|
|||
if (!jarReader)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsCOMPtr<nsIJAR> jar = do_QueryInterface(jarReader, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("nsIJAR not supported");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPrincipal> cert;
|
||||
rv = jar->GetCertificatePrincipal(mJarEntry.get(), getter_AddRefs(cert));
|
||||
rv = jarReader->GetCertificatePrincipal(mJarEntry.get(), getter_AddRefs(cert));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (cert) {
|
||||
|
|
|
@ -52,7 +52,6 @@ MODULES_LIBJAR_LEXPORTS = \
|
|||
|
||||
MODULES_LIBJAR_LXPIDLSRCS = \
|
||||
nsIZipReader.idl \
|
||||
nsIJAR.idl \
|
||||
nsIJARChannel.idl \
|
||||
nsIJARURI.idl \
|
||||
nsIJARProtocolHandler.idl \
|
||||
|
|
|
@ -38,7 +38,7 @@ function openZip(path) {
|
|||
var zip = Cc["@mozilla.org/libjar/zip-reader;1"].
|
||||
createInstance(Ci.nsIZipReader);
|
||||
zip.open(resolved);
|
||||
return zip.QueryInterface(Ci.nsIJAR);
|
||||
return zip;
|
||||
}
|
||||
|
||||
// Gets the pretty name from the signing cert or null if the zip is unsigned.
|
||||
|
|
|
@ -2809,7 +2809,6 @@ ExtensionManager.prototype = {
|
|||
var prettyName = "";
|
||||
try {
|
||||
var zipReader = getZipReaderForFile(entry);
|
||||
zipReader.QueryInterface(Ci.nsIJAR);
|
||||
var principal = zipReader.getCertificatePrincipal(null);
|
||||
if (principal && principal.hasCertificate) {
|
||||
if (verifyZipSigning(zipReader, principal)) {
|
||||
|
|
|
@ -47,7 +47,6 @@
|
|||
|
||||
#include "nsIURL.h"
|
||||
#include "nsIFileURL.h"
|
||||
#include "nsIJAR.h"
|
||||
|
||||
#include "nsITransport.h"
|
||||
#include "nsIOutputStream.h"
|
||||
|
@ -635,13 +634,9 @@ VerifySigning(nsIZipReader* hZip, nsIPrincipal* aPrincipal)
|
|||
if (!hasCert)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIJAR> jar(do_QueryInterface(hZip));
|
||||
if (!jar)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// See if the archive is signed at all first
|
||||
nsCOMPtr<nsIPrincipal> principal;
|
||||
nsresult rv = jar->GetCertificatePrincipal(nsnull, getter_AddRefs(principal));
|
||||
nsresult rv = hZip->GetCertificatePrincipal(nsnull, getter_AddRefs(principal));
|
||||
if (NS_FAILED(rv) || !principal)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -670,7 +665,7 @@ VerifySigning(nsIZipReader* hZip, nsIPrincipal* aPrincipal)
|
|||
entryCount++;
|
||||
|
||||
// Each entry must be signed
|
||||
rv = jar->GetCertificatePrincipal(name.get(), getter_AddRefs(principal));
|
||||
rv = hZip->GetCertificatePrincipal(name.get(), getter_AddRefs(principal));
|
||||
if (NS_FAILED(rv) || !principal) return NS_ERROR_FAILURE;
|
||||
|
||||
PRBool equal;
|
||||
|
@ -680,7 +675,7 @@ VerifySigning(nsIZipReader* hZip, nsIPrincipal* aPrincipal)
|
|||
|
||||
// next verify all files in the manifest are in the archive.
|
||||
PRUint32 manifestEntryCount;
|
||||
rv = jar->GetManifestEntriesCount(&manifestEntryCount);
|
||||
rv = hZip->GetManifestEntriesCount(&manifestEntryCount);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче