2001-01-10 01:32:29 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* 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.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Hubbie Shaw
|
|
|
|
* Doug Turner <dougt@netscape.com>
|
|
|
|
* Brian Ryner <bryner@netscape.com>
|
|
|
|
*/
|
|
|
|
|
2001-01-19 01:12:10 +00:00
|
|
|
#ifndef _nsNSSComponent_h_
|
|
|
|
#define _nsNSSComponent_h_
|
|
|
|
|
2001-02-06 20:09:27 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2001-01-10 01:32:29 +00:00
|
|
|
#include "nsISecurityManagerComponent.h"
|
|
|
|
#include "nsISignatureVerifier.h"
|
2001-02-26 21:50:54 +00:00
|
|
|
#include "nsIURIContentListener.h"
|
2001-01-25 01:14:23 +00:00
|
|
|
#include "nsIEntropyCollector.h"
|
|
|
|
#include "nsString.h"
|
2001-02-06 20:09:27 +00:00
|
|
|
#include "nsIStringBundle.h"
|
2001-01-10 01:32:29 +00:00
|
|
|
|
2001-02-10 02:53:10 +00:00
|
|
|
#include "nsNSSHelper.h"
|
|
|
|
|
2001-01-10 01:32:29 +00:00
|
|
|
#define SECURITY_STRING_BUNDLE_URL "chrome://communicator/locale/security.properties"
|
|
|
|
|
|
|
|
#define NS_NSSCOMPONENT_CID \
|
|
|
|
{0xa277189c, 0x1dd1, 0x11b2, {0xa8, 0xc9, 0xe4, 0xe8, 0xbf, 0xb1, 0x33, 0x8e}}
|
|
|
|
|
2001-02-07 19:00:52 +00:00
|
|
|
//Define an interface that we can use to look up from the
|
|
|
|
//callbacks passed to NSS.
|
|
|
|
|
|
|
|
#define NS_INSSCOMPONENT_IID_STR "d4b49dd6-1dd1-11b2-b6fe-b14cfaf69cbd"
|
|
|
|
#define NS_INSSCOMPONENT_IID \
|
|
|
|
{0xd4b49dd6, 0x1dd1, 0x11b2, \
|
|
|
|
{ 0xb6, 0xfe, 0xb1, 0x4c, 0xfa, 0xf6, 0x9c, 0xbd }}
|
|
|
|
|
2001-02-26 21:50:54 +00:00
|
|
|
#define NS_CERTCONTENTLISTEN_CID {0xc94f4a30, 0x64d7, 0x11d4, {0x99, 0x60, 0x00, 0xb0, 0xd0, 0x23, 0x54, 0xa0}}
|
|
|
|
#define NS_CERTCONTENTLISTEN_CONTRACTID "@mozilla.org/security/certdownload;1"
|
|
|
|
|
|
|
|
|
2001-02-07 19:00:52 +00:00
|
|
|
class NS_NO_VTABLE nsINSSComponent : public nsISupports {
|
|
|
|
public:
|
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(NS_INSSCOMPONENT_IID)
|
|
|
|
|
|
|
|
NS_IMETHOD GetPIPNSSBundleString(const PRUnichar *name,
|
|
|
|
nsString &outString) = 0;
|
|
|
|
NS_IMETHOD PIPBundleFormatStringFromName(const PRUnichar *name,
|
|
|
|
const PRUnichar **params,
|
|
|
|
PRUint32 numParams,
|
|
|
|
PRUnichar **outString) = 0;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-01-10 01:32:29 +00:00
|
|
|
// Implementation of the PSM component interface.
|
|
|
|
class nsNSSComponent : public nsISecurityManagerComponent,
|
2001-01-25 01:14:23 +00:00
|
|
|
public nsISignatureVerifier,
|
2001-02-07 19:00:52 +00:00
|
|
|
public nsIEntropyCollector,
|
|
|
|
public nsINSSComponent
|
2001-01-10 01:32:29 +00:00
|
|
|
{
|
|
|
|
public:
|
2001-01-25 01:14:23 +00:00
|
|
|
NS_DEFINE_STATIC_CID_ACCESSOR( NS_NSSCOMPONENT_CID );
|
|
|
|
|
2001-01-10 01:32:29 +00:00
|
|
|
nsNSSComponent();
|
|
|
|
virtual ~nsNSSComponent();
|
2001-01-19 01:12:10 +00:00
|
|
|
|
2001-01-10 01:32:29 +00:00
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSISECURITYMANAGERCOMPONENT
|
|
|
|
NS_DECL_NSISIGNATUREVERIFIER
|
2001-01-25 01:14:23 +00:00
|
|
|
NS_DECL_NSIENTROPYCOLLECTOR
|
2001-01-19 01:12:10 +00:00
|
|
|
|
|
|
|
NS_METHOD Init();
|
2001-02-06 20:09:27 +00:00
|
|
|
|
2001-02-07 19:00:52 +00:00
|
|
|
NS_IMETHOD GetPIPNSSBundleString(const PRUnichar *name,
|
|
|
|
nsString &outString);
|
|
|
|
NS_IMETHOD PIPBundleFormatStringFromName(const PRUnichar *name,
|
|
|
|
const PRUnichar **params,
|
|
|
|
PRUint32 numParams,
|
|
|
|
PRUnichar **outString);
|
2001-02-06 20:09:27 +00:00
|
|
|
nsresult InitializeNSS();
|
|
|
|
|
2001-01-25 01:14:23 +00:00
|
|
|
private:
|
2001-02-06 20:09:27 +00:00
|
|
|
|
2001-01-25 01:14:23 +00:00
|
|
|
void InstallLoadableRoots();
|
2001-02-06 20:09:27 +00:00
|
|
|
nsresult InitializePIPNSSBundle();
|
2001-02-14 22:15:53 +00:00
|
|
|
nsresult ConfigureInternalPKCS11Token();
|
|
|
|
char * GetPK11String(const PRUnichar *name, PRUint32 len);
|
2001-02-26 21:50:54 +00:00
|
|
|
nsresult RegisterCertContentListener();
|
2001-02-06 20:09:27 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIStringBundle> mPIPNSSBundle;
|
2001-02-26 21:50:54 +00:00
|
|
|
nsCOMPtr<nsIURIContentListener> mCertContentListener;
|
2001-02-06 20:09:27 +00:00
|
|
|
static PRBool mNSSInitialized;
|
2001-01-10 01:32:29 +00:00
|
|
|
};
|
2001-01-19 01:12:10 +00:00
|
|
|
|
2001-02-26 21:50:54 +00:00
|
|
|
//--------------------------------------------
|
|
|
|
// Now we need a content listener to register
|
|
|
|
//--------------------------------------------
|
|
|
|
|
|
|
|
class CertContentListener : public nsIURIContentListener {
|
|
|
|
public:
|
|
|
|
CertContentListener();
|
|
|
|
virtual ~CertContentListener();
|
|
|
|
nsresult init();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIURICONTENTLISTENER
|
|
|
|
private:
|
|
|
|
nsCOMPtr<nsISupports> mLoadCookie;
|
|
|
|
nsCOMPtr<nsIURIContentListener> mParentContentListener;
|
|
|
|
};
|
|
|
|
|
2001-01-19 01:12:10 +00:00
|
|
|
#endif // _nsNSSComponent_h_
|
|
|
|
|