Line data Source code
1 : /* This Source Code Form is subject to the terms of the Mozilla Public
2 : * License, v. 2.0. If a copy of the MPL was not distributed with this
3 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 :
5 : #ifndef nsNSSCertificateDB_h
6 : #define nsNSSCertificateDB_h
7 :
8 : #include "ScopedNSSTypes.h"
9 : #include "certt.h"
10 : #include "mozilla/Mutex.h"
11 : #include "mozilla/NotNull.h"
12 : #include "mozilla/RefPtr.h"
13 : #include "mozilla/UniquePtr.h"
14 : #include "nsIX509CertDB.h"
15 : #include "nsNSSShutDown.h"
16 : #include "nsString.h"
17 :
18 : class nsCString;
19 : class nsIArray;
20 :
21 0 : class nsNSSCertificateDB final : public nsIX509CertDB
22 : , public nsNSSShutDownObject
23 :
24 : {
25 : public:
26 : NS_DECL_THREADSAFE_ISUPPORTS
27 : NS_DECL_NSIX509CERTDB
28 :
29 : // Use this function to generate a default nickname for a user
30 : // certificate that is to be imported onto a token.
31 : static void
32 : get_default_nickname(CERTCertificate *cert, nsIInterfaceRequestor* ctx,
33 : nsCString &nickname,
34 : const nsNSSShutDownPreventionLock &proofOfLock);
35 :
36 : static nsresult
37 : ImportValidCACerts(int numCACerts, SECItem *CACerts, nsIInterfaceRequestor *ctx,
38 : const nsNSSShutDownPreventionLock &proofOfLock);
39 :
40 : // This is a separate static method so nsNSSComponent can use it during NSS
41 : // initialization. Other code should probably not use it.
42 : static nsresult
43 : FindCertByDBKey(const nsACString& aDBKey, mozilla::UniqueCERTCertificate& cert);
44 :
45 : protected:
46 : virtual ~nsNSSCertificateDB();
47 :
48 : private:
49 :
50 : static nsresult
51 : ImportValidCACertsInList(const mozilla::UniqueCERTCertList& filteredCerts,
52 : nsIInterfaceRequestor* ctx,
53 : const nsNSSShutDownPreventionLock& proofOfLock);
54 :
55 : static void DisplayCertificateAlert(nsIInterfaceRequestor *ctx,
56 : const char *stringID, nsIX509Cert *certToShow,
57 : const nsNSSShutDownPreventionLock &proofOfLock);
58 :
59 : CERTDERCerts* getCertsFromPackage(const mozilla::UniquePLArenaPool& arena,
60 : uint8_t* data, uint32_t length,
61 : const nsNSSShutDownPreventionLock& proofOfLock);
62 : nsresult handleCACertDownload(mozilla::NotNull<nsIArray*> x509Certs,
63 : nsIInterfaceRequestor *ctx,
64 : const nsNSSShutDownPreventionLock &proofOfLock);
65 :
66 : // We don't own any NSS objects here, so no need to clean up
67 0 : virtual void virtualDestroyNSSReference() override { };
68 : };
69 :
70 : #define NS_X509CERTDB_CID { /* fb0bbc5c-452e-4783-b32c-80124693d871 */ \
71 : 0xfb0bbc5c, \
72 : 0x452e, \
73 : 0x4783, \
74 : {0xb3, 0x2c, 0x80, 0x12, 0x46, 0x93, 0xd8, 0x71} \
75 : }
76 :
77 : #endif // nsNSSCertificateDB_h
|