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 nsNSSCertTrust_h
6 : #define nsNSSCertTrust_h
7 :
8 : #include "certdb.h"
9 : #include "certt.h"
10 :
11 : /*
12 : * Class for maintaining trust flags for an NSS certificate.
13 : */
14 : class nsNSSCertTrust
15 : {
16 : public:
17 : nsNSSCertTrust();
18 : nsNSSCertTrust(unsigned int ssl, unsigned int email, unsigned int objsign);
19 : explicit nsNSSCertTrust(CERTCertTrust *t);
20 : virtual ~nsNSSCertTrust();
21 :
22 : /* query */
23 : bool HasAnyCA();
24 : bool HasAnyUser();
25 : bool HasPeer(bool checkSSL = true,
26 : bool checkEmail = true,
27 : bool checkObjSign = true);
28 : bool HasTrustedCA(bool checkSSL = true,
29 : bool checkEmail = true,
30 : bool checkObjSign = true);
31 : bool HasTrustedPeer(bool checkSSL = true,
32 : bool checkEmail = true,
33 : bool checkObjSign = true);
34 :
35 : /* common defaults */
36 : /* equivalent to "c,c,c" */
37 : void SetValidCA();
38 : /* equivalent to "p,p,p" */
39 : void SetValidPeer();
40 :
41 : /* general setters */
42 : /* read: "p, P, c, C, T, u, w" */
43 : void SetSSLTrust(bool peer, bool tPeer,
44 : bool ca, bool tCA, bool tClientCA,
45 : bool user, bool warn);
46 :
47 : void SetEmailTrust(bool peer, bool tPeer,
48 : bool ca, bool tCA, bool tClientCA,
49 : bool user, bool warn);
50 :
51 : void SetObjSignTrust(bool peer, bool tPeer,
52 : bool ca, bool tCA, bool tClientCA,
53 : bool user, bool warn);
54 :
55 : /* set c <--> CT */
56 : void AddCATrust(bool ssl, bool email, bool objSign);
57 : /* set p <--> P */
58 : void AddPeerTrust(bool ssl, bool email, bool objSign);
59 :
60 : /* get it (const?) (shallow?) */
61 0 : CERTCertTrust * GetTrust() { return &mTrust; }
62 :
63 : private:
64 : void addTrust(unsigned int *t, unsigned int v);
65 : void removeTrust(unsigned int *t, unsigned int v);
66 : bool hasTrust(unsigned int t, unsigned int v);
67 : CERTCertTrust mTrust;
68 : };
69 :
70 : #endif // nsNSSCertTrust_h
|