|
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 "nsIX509CertDB.h" |
|
9 #include "nsIX509CertDB2.h" |
|
10 #include "nsNSSShutDown.h" |
|
11 #include "mozilla/RefPtr.h" |
|
12 #include "mozilla/Mutex.h" |
|
13 #include "certt.h" |
|
14 |
|
15 class nsCString; |
|
16 class nsIArray; |
|
17 class nsRecentBadCerts; |
|
18 |
|
19 class nsNSSCertificateDB : public nsIX509CertDB |
|
20 , public nsIX509CertDB2 |
|
21 , public nsNSSShutDownObject |
|
22 |
|
23 { |
|
24 public: |
|
25 NS_DECL_THREADSAFE_ISUPPORTS |
|
26 NS_DECL_NSIX509CERTDB |
|
27 NS_DECL_NSIX509CERTDB2 |
|
28 |
|
29 nsNSSCertificateDB(); |
|
30 virtual ~nsNSSCertificateDB(); |
|
31 |
|
32 // Use this function to generate a default nickname for a user |
|
33 // certificate that is to be imported onto a token. |
|
34 static void |
|
35 get_default_nickname(CERTCertificate *cert, nsIInterfaceRequestor* ctx, |
|
36 nsCString &nickname, |
|
37 const nsNSSShutDownPreventionLock &proofOfLock); |
|
38 |
|
39 static nsresult |
|
40 ImportValidCACerts(int numCACerts, SECItem *CACerts, nsIInterfaceRequestor *ctx, |
|
41 const nsNSSShutDownPreventionLock &proofOfLock); |
|
42 |
|
43 private: |
|
44 |
|
45 static nsresult |
|
46 ImportValidCACertsInList(CERTCertList *certList, nsIInterfaceRequestor *ctx, |
|
47 const nsNSSShutDownPreventionLock &proofOfLock); |
|
48 |
|
49 static void DisplayCertificateAlert(nsIInterfaceRequestor *ctx, |
|
50 const char *stringID, nsIX509Cert *certToShow, |
|
51 const nsNSSShutDownPreventionLock &proofOfLock); |
|
52 |
|
53 void getCertNames(CERTCertList *certList, |
|
54 uint32_t type, |
|
55 uint32_t *_count, |
|
56 char16_t ***_certNameList, |
|
57 const nsNSSShutDownPreventionLock &proofOfLock); |
|
58 |
|
59 CERTDERCerts *getCertsFromPackage(PLArenaPool *arena, uint8_t *data, |
|
60 uint32_t length, |
|
61 const nsNSSShutDownPreventionLock &proofOfLock); |
|
62 nsresult handleCACertDownload(nsIArray *x509Certs, |
|
63 nsIInterfaceRequestor *ctx, |
|
64 const nsNSSShutDownPreventionLock &proofOfLock); |
|
65 |
|
66 mozilla::Mutex mBadCertsLock; |
|
67 mozilla::RefPtr<nsRecentBadCerts> mPublicRecentBadCerts; |
|
68 mozilla::RefPtr<nsRecentBadCerts> mPrivateRecentBadCerts; |
|
69 |
|
70 // We don't own any NSS objects here, so no need to clean up |
|
71 virtual void virtualDestroyNSSReference() { }; |
|
72 }; |
|
73 |
|
74 #define NS_X509CERTDB_CID { /* fb0bbc5c-452e-4783-b32c-80124693d871 */ \ |
|
75 0xfb0bbc5c, \ |
|
76 0x452e, \ |
|
77 0x4783, \ |
|
78 {0xb3, 0x2c, 0x80, 0x12, 0x46, 0x93, 0xd8, 0x71} \ |
|
79 } |
|
80 |
|
81 #endif |