/security/manager/ssl/src/nsNSSCertTrust.h

http://github.com/zpao/v8monkey · C Header · 122 lines · 54 code · 12 blank · 56 comment · 0 complexity · 54b433d179a23a96801c4f9a3a0e13de MD5 · raw file

  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. #ifndef _NSNSSCERTTRUST_H_
  39. #define _NSNSSCERTTRUST_H_
  40. #include "certt.h"
  41. #include "certdb.h"
  42. /*
  43. * nsNSSCertTrust
  44. *
  45. * Class for maintaining trust flags for an NSS certificate.
  46. */
  47. class nsNSSCertTrust
  48. {
  49. public:
  50. nsNSSCertTrust();
  51. nsNSSCertTrust(unsigned int ssl, unsigned int email, unsigned int objsign);
  52. nsNSSCertTrust(CERTCertTrust *t);
  53. virtual ~nsNSSCertTrust();
  54. /* query */
  55. bool HasAnyCA();
  56. bool HasAnyUser();
  57. bool HasCA(bool checkSSL = true,
  58. bool checkEmail = true,
  59. bool checkObjSign = true);
  60. bool HasPeer(bool checkSSL = true,
  61. bool checkEmail = true,
  62. bool checkObjSign = true);
  63. bool HasUser(bool checkSSL = true,
  64. bool checkEmail = true,
  65. bool checkObjSign = true);
  66. bool HasTrustedCA(bool checkSSL = true,
  67. bool checkEmail = true,
  68. bool checkObjSign = true);
  69. bool HasTrustedPeer(bool checkSSL = true,
  70. bool checkEmail = true,
  71. bool checkObjSign = true);
  72. /* common defaults */
  73. /* equivalent to "c,c,c" */
  74. void SetValidCA();
  75. /* equivalent to "C,C,C" */
  76. void SetTrustedServerCA();
  77. /* equivalent to "CT,CT,CT" */
  78. void SetTrustedCA();
  79. /* equivalent to "p,," */
  80. void SetValidServerPeer();
  81. /* equivalent to "p,p,p" */
  82. void SetValidPeer();
  83. /* equivalent to "P,P,P" */
  84. void SetTrustedPeer();
  85. /* equivalent to "u,u,u" */
  86. void SetUser();
  87. /* general setters */
  88. /* read: "p, P, c, C, T, u, w" */
  89. void SetSSLTrust(bool peer, bool tPeer,
  90. bool ca, bool tCA, bool tClientCA,
  91. bool user, bool warn);
  92. void SetEmailTrust(bool peer, bool tPeer,
  93. bool ca, bool tCA, bool tClientCA,
  94. bool user, bool warn);
  95. void SetObjSignTrust(bool peer, bool tPeer,
  96. bool ca, bool tCA, bool tClientCA,
  97. bool user, bool warn);
  98. /* set c <--> CT */
  99. void AddCATrust(bool ssl, bool email, bool objSign);
  100. /* set p <--> P */
  101. void AddPeerTrust(bool ssl, bool email, bool objSign);
  102. /* get it (const?) (shallow?) */
  103. CERTCertTrust * GetTrust() { return &mTrust; }
  104. private:
  105. void addTrust(unsigned int *t, unsigned int v);
  106. void removeTrust(unsigned int *t, unsigned int v);
  107. bool hasTrust(unsigned int t, unsigned int v);
  108. CERTCertTrust mTrust;
  109. };
  110. #endif