Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

194 lines
7.5 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 2000-2001.
  5. //
  6. // File: CertTemplate.h
  7. //
  8. // Contents: CCertTemplate
  9. //
  10. //----------------------------------------------------------------------------
  11. /// CertTemplate.h: interface for the CCertTemplate class.
  12. //
  13. //////////////////////////////////////////////////////////////////////
  14. #if !defined(AFX_CERTTEMPLATE_H__2562C528_F60F_4F4B_9E2A_FBD96732369C__INCLUDED_)
  15. #define AFX_CERTTEMPLATE_H__2562C528_F60F_4F4B_9E2A_FBD96732369C__INCLUDED_
  16. #if _MSC_VER > 1000
  17. #pragma once
  18. #endif // _MSC_VER > 1000
  19. #include "cookie.h"
  20. typedef enum {
  21. PERIOD_TYPE_NONE = -1,
  22. PERIOD_TYPE_DAY = 0,
  23. PERIOD_TYPE_WEEK,
  24. PERIOD_TYPE_MONTH,
  25. PERIOD_TYPE_YEAR
  26. } PERIOD_TYPE;
  27. class CCertTemplate : public CCertTmplCookie
  28. {
  29. public:
  30. CCertTemplate(
  31. PCWSTR pszObjectName,
  32. PCWSTR pszTemplateName,
  33. const CString& szLDAPPath,
  34. bool fIsReadOnly,
  35. const bool fUseCache);
  36. CCertTemplate (
  37. const CCertTemplate& rTemplate,
  38. bool bIsClone,
  39. bool fIsReadOnly,
  40. const bool fUseCache);
  41. virtual ~CCertTemplate();
  42. public:
  43. bool IssuancePoliciesRequired () const;
  44. void IssuancePoliciesRequired (bool bRequired);
  45. HRESULT GetDigitalSignature(bool &bHasDigitalSignature);
  46. HRESULT SetDigitalSignature (bool bSet);
  47. HRESULT GetSubjectTypeDescription (int nIndex, CString &szSubjectTypeDescription);
  48. // bool AllowAutoenrollment (); /* NO LONGER NEEDED NTRAID# 321742 */
  49. bool UserInteractionRequired () const;
  50. HRESULT SetUserInteractionRequired(bool bSet);
  51. bool RemoveInvalidCertFromPersonalStore () const;
  52. HRESULT SetRemoveInvalidCertFromPersonalStore(bool bRemove);
  53. HRESULT IsExtensionCritical (PCWSTR szExtension, bool& bCritical);
  54. HRESULT ModifyCriticalExtensions (const CString &szExtension, bool bAdd);
  55. HRESULT Cancel();
  56. void FreeCertExtensions ();
  57. HRESULT GetEnhancedKeyUsage (int nIndex, CString &szEKU);
  58. HRESULT SetEnhancedKeyUsage (const PWSTR* pawszEKU, bool bCritical);
  59. HRESULT GetApplicationPolicy (int nIndex, CString &szAppPolicy);
  60. HRESULT SetApplicationPolicy (const PWSTR* pawszAppPolicy, bool bCritical);
  61. HRESULT SetCertPolicy (const PWSTR* pawszCertPolicy, bool bCritical);
  62. HRESULT SetCheckDSCert (bool bIgnore);
  63. bool CheckDSCert () const;
  64. HRESULT SetBasicConstraints(PCERT_BASIC_CONSTRAINTS2_INFO pBCInfo,
  65. bool bCritical);
  66. HRESULT SetKeyUsage (CRYPT_BIT_BLOB* pKeyUsage, bool bCritical);
  67. bool GoodForAutoEnrollment () const;
  68. HRESULT IncrementMinorVersion ();
  69. HRESULT IncrementMajorVersion ();
  70. HRESULT GetMinorVersion (DWORD& dwMinorVersion) const;
  71. HRESULT GetMajorVersion (DWORD& dwMajorVersion) const;
  72. HRESULT SetPendAllRequests (bool bPend);
  73. bool PendAllRequests () const;
  74. HRESULT SetReenrollmentValidWithPreviousApproval (bool bValid);
  75. bool ReenrollmentValidWithPreviousApproval () const;
  76. HRESULT SetRANumSignaturesRequired (DWORD dwNumSignaturesRequired);
  77. HRESULT GetRANumSignaturesRequired (DWORD& dwNumSignatures);
  78. HRESULT SetPublishToDS (bool bPublish);
  79. HRESULT SetRenewalPeriod (int nDays);
  80. HRESULT SetValidityPeriod (int nDays);
  81. CString GetLDAPPath () const;
  82. HRESULT GetSecurity (PSECURITY_DESCRIPTOR* ppSD) const;
  83. HRESULT SetSecurity (PSECURITY_DESCRIPTOR pSD);
  84. bool ReadOnly () const;
  85. HRESULT GetSupercededTemplate (int nIndex, CString& szSupercededTemplate);
  86. HRESULT ModifySupercededTemplateList(const CString &szSupercededTemplateName,
  87. bool bAdd);
  88. HRESULT GetCSP (int nIndex, CString& szCSP);
  89. HRESULT GetCertPolicy (int nIndex, CString& szCertPolicy);
  90. HRESULT ModifyCSPList(const CString &szCSPName, bool bAdd);
  91. HRESULT GetRAIssuancePolicy(int nIndex, CString& szRAPolicyOID);
  92. HRESULT GetRAApplicationPolicy(int nIndex, CString& szRAPolicyOID);
  93. HRESULT ModifyRAIssuancePolicyList(const CString &szRAPolicyOID, bool bAdd);
  94. HRESULT ModifyRAApplicationPolicyList(const CString &szRAPolicyOID, bool bAdd);
  95. HRESULT SetMinimumKeySizeValue (DWORD dwMinKeySize);
  96. HRESULT AltNameIncludesSPN (bool bIncludesSPN);
  97. bool AltNameIncludesSPN () const;
  98. HRESULT RequireSubjectInRequest (bool bRequire);
  99. HRESULT SubjectNameMustBeCN (bool bMustBeCN);
  100. bool SubjectNameMustBeCN () const;
  101. HRESULT SubjectNameMustBeFullDN (bool bMustBeDN);
  102. bool SubjectNameMustBeFullDN () const;
  103. HRESULT SubjectNameIncludesEMail (bool bIncludesEMail);
  104. bool SubjectNameIncludesEMail () const;
  105. HRESULT AltNameIncludesUPN (bool bIncludesUPN);
  106. bool AltNameIncludesUPN () const;
  107. HRESULT AltNameIncludesEMail (bool bIncludesEMail);
  108. bool AltNameIncludesEMail () const;
  109. HRESULT AltNameIncludesDNS (bool fIncludeDNS);
  110. bool AltNameIncludesDNS () const;
  111. HRESULT DoAutoEnrollmentPendingSave ();
  112. HRESULT IncludeSymmetricAlgorithems (bool bInclude);
  113. bool IncludeSymmetricAlgorithms () const;
  114. HRESULT AllowPrivateKeyArchival (bool bAllowArchival);
  115. bool AllowPrivateKeyArchival () const;
  116. HRESULT MakePrivateKeyExportable (bool bMakeExportable);
  117. bool PrivateKeyIsExportable () const;
  118. HRESULT GetMinimumKeySize (DWORD& dwMinKeySize) const;
  119. HRESULT SetAutoEnrollment (bool bSuitableForAutoEnrollment);
  120. bool CanBeDeletedOnCancel () const;
  121. HRESULT SetEncryptionSignature (bool bHasEncryptionSignature);
  122. HRESULT SetKeySpecSignature (bool bHasKeySpecSignature);
  123. HRESULT SetSubjectIsCA (bool bSubjectIsCA);
  124. HRESULT SaveChanges (bool bIncrementMinorVersion = true);
  125. HRESULT SetDisplayName (const CString& strDisplayName, bool bForce = false);
  126. HRESULT SetTemplateName (const CString& strTemplateName);
  127. bool IsClone () const;
  128. bool IsDefault () const;
  129. HRESULT Delete ();
  130. HRESULT Clone (
  131. const CCertTemplate& rTemplate,
  132. const CString& strTemplateName,
  133. const CString& strDisplayName);
  134. HRESULT GetValidityPeriod (int& nValidityDays);
  135. HRESULT GetRenewalPeriod (int& nRenewalDays);
  136. bool RequireSubjectInRequest () const;
  137. bool HasEncryptionSignature () const;
  138. bool HasKeySpecSignature () const;
  139. HRESULT GetCertExtension (DWORD dwIndex, PSTR* ppszObjId, BOOL& fCritical);
  140. HRESULT GetCertExtension (PSTR pszOID, PCERT_EXTENSION* ppCertExtension);
  141. DWORD GetCertExtensionCount ();
  142. bool PublishToDS () const;
  143. bool IsMachineType () const;
  144. bool SubjectIsCA() const;
  145. bool SubjectIsCrossCA() const;
  146. CString GetTemplateName() const;
  147. CString GetDisplayName ();
  148. DWORD GetType() const;
  149. protected:
  150. HRESULT ConvertCertTypeFileTimeToDays (FILETIME const *pftCertType, int& nDays);
  151. private:
  152. bool m_bIssuancePoliciesRequired;
  153. PCERT_EXTENSIONS m_pCertExtensions;
  154. int m_nNewRenewalDays;
  155. int m_nOriginalRenewalDays;
  156. int m_nNewValidityDays;
  157. int m_nOriginalValidityDays;
  158. const bool m_fIsReadOnly;
  159. bool m_bGoodForAutoenrollmentFlagPendingSave;
  160. bool m_bCanBeDeletedOnCancel;
  161. HRESULT SetFlag (DWORD dwFlagType, DWORD dwFlag, bool bValue);
  162. CString m_strOriginalTemplateName;
  163. bool m_bIsClone;
  164. DWORD m_dwKeySpec;
  165. DWORD m_dwEnrollmentFlags;
  166. DWORD m_dwSubjectNameFlags;
  167. DWORD m_dwPrivateKeyFlags;
  168. DWORD m_dwGeneralFlags;
  169. DWORD m_dwVersion;
  170. HCERTTYPE m_hCertType;
  171. CString m_strTemplateName;
  172. const CString m_szLDAPPath;
  173. CString m_szDisplayName;
  174. const bool m_fUseCache;
  175. protected:
  176. HRESULT ModifyStringList(const CString& szPropertyName,
  177. PWSTR** ppStringList,
  178. const CString &szCSPName,
  179. bool bAdd);
  180. HRESULT Initialize ();
  181. };
  182. #endif // !defined(AFX_CERTTEMPLATE_H__2562C528_F60F_4F4B_9E2A_FBD96732369C__INCLUDED_)