| OLD | NEW |
| (Empty) |
| 1 /* ***** BEGIN LICENSE BLOCK ***** | |
| 2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | |
| 3 * | |
| 4 * The contents of this file are subject to the Mozilla Public License Version | |
| 5 * 1.1 (the "License"); you may not use this file except in compliance with | |
| 6 * the License. You may obtain a copy of the License at | |
| 7 * http://www.mozilla.org/MPL/ | |
| 8 * | |
| 9 * Software distributed under the License is distributed on an "AS IS" basis, | |
| 10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |
| 11 * for the specific language governing rights and limitations under the | |
| 12 * License. | |
| 13 * | |
| 14 * The Original Code is the Netscape security libraries. | |
| 15 * | |
| 16 * The Initial Developer of the Original Code is | |
| 17 * Netscape Communications Corporation. | |
| 18 * Portions created by the Initial Developer are Copyright (C) 2000 | |
| 19 * the Initial Developer. All Rights Reserved. | |
| 20 * | |
| 21 * Contributor(s): | |
| 22 * Ian McGreer <mcgreer@netscape.com> | |
| 23 * Javier Delgadillo <javi@netscape.com> | |
| 24 * | |
| 25 * Alternatively, the contents of this file may be used under the terms of | |
| 26 * either the GNU General Public License Version 2 or later (the "GPL"), or | |
| 27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), | |
| 28 * in which case the provisions of the GPL or the LGPL are applicable instead | |
| 29 * of those above. If you wish to allow use of your version of this file only | |
| 30 * under the terms of either the GPL or the LGPL, and not to allow others to | |
| 31 * use your version of this file under the terms of the MPL, indicate your | |
| 32 * decision by deleting the provisions above and replace them with the notice | |
| 33 * and other provisions required by the GPL or the LGPL. If you do not delete | |
| 34 * the provisions above, a recipient may use your version of this file under | |
| 35 * the terms of any one of the MPL, the GPL or the LGPL. | |
| 36 * | |
| 37 * ***** END LICENSE BLOCK ***** */ | |
| 38 | |
| 39 #ifndef NET_THIRD_PARTY_MOZILLA_SECURITY_MANAGER_NSNSSCERTTRUST_H_ | |
| 40 #define NET_THIRD_PARTY_MOZILLA_SECURITY_MANAGER_NSNSSCERTTRUST_H_ | |
| 41 | |
| 42 #include <certt.h> | |
| 43 #include <certdb.h> | |
| 44 | |
| 45 #include "net/base/net_export.h" | |
| 46 | |
| 47 namespace mozilla_security_manager { | |
| 48 | |
| 49 /* | |
| 50 * nsNSSCertTrust | |
| 51 * | |
| 52 * Class for maintaining trust flags for an NSS certificate. | |
| 53 */ | |
| 54 class NET_EXPORT nsNSSCertTrust | |
| 55 { | |
| 56 public: | |
| 57 nsNSSCertTrust(); | |
| 58 nsNSSCertTrust(unsigned int ssl, unsigned int email, unsigned int objsign); | |
| 59 nsNSSCertTrust(CERTCertTrust *t); | |
| 60 virtual ~nsNSSCertTrust(); | |
| 61 | |
| 62 /* query */ | |
| 63 PRBool HasAnyCA(); | |
| 64 PRBool HasAnyUser(); | |
| 65 PRBool HasCA(PRBool checkSSL = PR_TRUE, | |
| 66 PRBool checkEmail = PR_TRUE, | |
| 67 PRBool checkObjSign = PR_TRUE); | |
| 68 PRBool HasPeer(PRBool checkSSL = PR_TRUE, | |
| 69 PRBool checkEmail = PR_TRUE, | |
| 70 PRBool checkObjSign = PR_TRUE); | |
| 71 PRBool HasUser(PRBool checkSSL = PR_TRUE, | |
| 72 PRBool checkEmail = PR_TRUE, | |
| 73 PRBool checkObjSign = PR_TRUE); | |
| 74 PRBool HasTrustedCA(PRBool checkSSL = PR_TRUE, | |
| 75 PRBool checkEmail = PR_TRUE, | |
| 76 PRBool checkObjSign = PR_TRUE); | |
| 77 PRBool HasTrustedPeer(PRBool checkSSL = PR_TRUE, | |
| 78 PRBool checkEmail = PR_TRUE, | |
| 79 PRBool checkObjSign = PR_TRUE); | |
| 80 | |
| 81 /* common defaults */ | |
| 82 /* equivalent to "c,c,c" */ | |
| 83 void SetValidCA(); | |
| 84 /* equivalent to "C,C,C" */ | |
| 85 void SetTrustedServerCA(); | |
| 86 /* equivalent to "CT,CT,CT" */ | |
| 87 void SetTrustedCA(); | |
| 88 /* equivalent to "p,," */ | |
| 89 void SetValidServerPeer(); | |
| 90 /* equivalent to "p,p,p" */ | |
| 91 void SetValidPeer(); | |
| 92 /* equivalent to "P,P,P" */ | |
| 93 void SetTrustedPeer(); | |
| 94 /* equivalent to "u,u,u" */ | |
| 95 void SetUser(); | |
| 96 | |
| 97 /* general setters */ | |
| 98 /* read: "p, P, c, C, T, u, w" */ | |
| 99 void SetSSLTrust(PRBool peer, PRBool tPeer, | |
| 100 PRBool ca, PRBool tCA, PRBool tClientCA, | |
| 101 PRBool user, PRBool warn); | |
| 102 | |
| 103 void SetEmailTrust(PRBool peer, PRBool tPeer, | |
| 104 PRBool ca, PRBool tCA, PRBool tClientCA, | |
| 105 PRBool user, PRBool warn); | |
| 106 | |
| 107 void SetObjSignTrust(PRBool peer, PRBool tPeer, | |
| 108 PRBool ca, PRBool tCA, PRBool tClientCA, | |
| 109 PRBool user, PRBool warn); | |
| 110 | |
| 111 /* set c <--> CT */ | |
| 112 void AddCATrust(PRBool ssl, PRBool email, PRBool objSign); | |
| 113 /* set p <--> P */ | |
| 114 void AddPeerTrust(PRBool ssl, PRBool email, PRBool objSign); | |
| 115 | |
| 116 /* get it (const?) (shallow?) */ | |
| 117 CERTCertTrust * GetTrust() { return &mTrust; } | |
| 118 | |
| 119 private: | |
| 120 void addTrust(unsigned int *t, unsigned int v); | |
| 121 void removeTrust(unsigned int *t, unsigned int v); | |
| 122 PRBool hasTrust(unsigned int t, unsigned int v); | |
| 123 CERTCertTrust mTrust; | |
| 124 }; | |
| 125 | |
| 126 } // namespace mozilla_security_manager | |
| 127 | |
| 128 #endif // NET_THIRD_PARTY_MOZILLA_SECURITY_MANAGER_NSNSSCERTTRUST_H_ | |
| OLD | NEW |