michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef __NSNSSCERTIFICATEDB_H__ michael@0: #define __NSNSSCERTIFICATEDB_H__ michael@0: michael@0: #include "nsIX509CertDB.h" michael@0: #include "nsIX509CertDB2.h" michael@0: #include "nsNSSShutDown.h" michael@0: #include "mozilla/RefPtr.h" michael@0: #include "mozilla/Mutex.h" michael@0: #include "certt.h" michael@0: michael@0: class nsCString; michael@0: class nsIArray; michael@0: class nsRecentBadCerts; michael@0: michael@0: class nsNSSCertificateDB : public nsIX509CertDB michael@0: , public nsIX509CertDB2 michael@0: , public nsNSSShutDownObject michael@0: michael@0: { michael@0: public: michael@0: NS_DECL_THREADSAFE_ISUPPORTS michael@0: NS_DECL_NSIX509CERTDB michael@0: NS_DECL_NSIX509CERTDB2 michael@0: michael@0: nsNSSCertificateDB(); michael@0: virtual ~nsNSSCertificateDB(); michael@0: michael@0: // Use this function to generate a default nickname for a user michael@0: // certificate that is to be imported onto a token. michael@0: static void michael@0: get_default_nickname(CERTCertificate *cert, nsIInterfaceRequestor* ctx, michael@0: nsCString &nickname, michael@0: const nsNSSShutDownPreventionLock &proofOfLock); michael@0: michael@0: static nsresult michael@0: ImportValidCACerts(int numCACerts, SECItem *CACerts, nsIInterfaceRequestor *ctx, michael@0: const nsNSSShutDownPreventionLock &proofOfLock); michael@0: michael@0: private: michael@0: michael@0: static nsresult michael@0: ImportValidCACertsInList(CERTCertList *certList, nsIInterfaceRequestor *ctx, michael@0: const nsNSSShutDownPreventionLock &proofOfLock); michael@0: michael@0: static void DisplayCertificateAlert(nsIInterfaceRequestor *ctx, michael@0: const char *stringID, nsIX509Cert *certToShow, michael@0: const nsNSSShutDownPreventionLock &proofOfLock); michael@0: michael@0: void getCertNames(CERTCertList *certList, michael@0: uint32_t type, michael@0: uint32_t *_count, michael@0: char16_t ***_certNameList, michael@0: const nsNSSShutDownPreventionLock &proofOfLock); michael@0: michael@0: CERTDERCerts *getCertsFromPackage(PLArenaPool *arena, uint8_t *data, michael@0: uint32_t length, michael@0: const nsNSSShutDownPreventionLock &proofOfLock); michael@0: nsresult handleCACertDownload(nsIArray *x509Certs, michael@0: nsIInterfaceRequestor *ctx, michael@0: const nsNSSShutDownPreventionLock &proofOfLock); michael@0: michael@0: mozilla::Mutex mBadCertsLock; michael@0: mozilla::RefPtr mPublicRecentBadCerts; michael@0: mozilla::RefPtr mPrivateRecentBadCerts; michael@0: michael@0: // We don't own any NSS objects here, so no need to clean up michael@0: virtual void virtualDestroyNSSReference() { }; michael@0: }; michael@0: michael@0: #define NS_X509CERTDB_CID { /* fb0bbc5c-452e-4783-b32c-80124693d871 */ \ michael@0: 0xfb0bbc5c, \ michael@0: 0x452e, \ michael@0: 0x4783, \ michael@0: {0xb3, 0x2c, 0x80, 0x12, 0x46, 0x93, 0xd8, 0x71} \ michael@0: } michael@0: michael@0: #endif