Leaked source code of windows server 2003
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.

183 lines
6.2 KiB

  1. VERSION 1.0 CLASS
  2. BEGIN
  3. MultiUse = -1 'True
  4. END
  5. Attribute VB_Name = "Policy"
  6. Attribute VB_GlobalNameSpace = False
  7. Attribute VB_Creatable = True
  8. Attribute VB_PredeclaredId = False
  9. Attribute VB_Exposed = True
  10. Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
  11. Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
  12. Option Explicit
  13. Private Const szOID_TEST1 As String = "0.1.2.3.4.5.6.0"
  14. Private Const szOID_TEST2 As String = "0.1.2.3.4.5.6.1"
  15. Private Const szOID_TEST3 As String = "0.1.2.3.4.5.6.2"
  16. Public Function Initialize( _
  17. strConfig As String)
  18. End Function
  19. Public Function ShutDown()
  20. End Function
  21. Public Function GetDescription() As String
  22. GetDescription = szDESCRIPTION
  23. End Function
  24. Public Function VerifyRequest( _
  25. strConfig As String, _
  26. Context As Long, _
  27. bNewRequest As Long, _
  28. Flags As Long) As Long
  29. Dim Str As String
  30. Dim PolicyForm As policyvb
  31. Dim CertServer As CCertServerPolicy
  32. Dim StringArray As CCertEncodeStringArray
  33. Dim Extension As String
  34. Dim NotBefore As Date
  35. Dim NotAfter As Date
  36. Set CertServer = New CCertServerPolicy
  37. Set StringArray = New CCertEncodeStringArray
  38. Set PolicyForm = New policyvb
  39. PolicyForm.Caption = szNAME
  40. CertServer.SetContext Context
  41. 'Collect user information from the request:
  42. On Error Resume Next
  43. Str = ""
  44. Str = CertServer.GetRequestProperty(wszPROPSUBJECTDOT & wszPROPCOMMONNAME, PROPTYPE_STRING)
  45. On Error GoTo 0
  46. If (Len(Str) <> 0) Then
  47. CertServer.SetCertificateProperty wszPROPSUBJECTDOT & wszPROPCOMMONNAME, PROPTYPE_STRING, Str
  48. End If
  49. PolicyForm.NameText.Text = Str
  50. On Error Resume Next
  51. PolicyForm.VersionText.Text = ""
  52. Str = ""
  53. Str = CertServer.GetRequestAttribute(wszCERT_VERSION)
  54. PolicyForm.VersionText.Text = Str
  55. On Error Resume Next
  56. PolicyForm.RequestTypeText.Text = ""
  57. Str = ""
  58. Str = CertServer.GetRequestAttribute(wszCERT_TYPE)
  59. PolicyForm.RequestTypeText.Text = Str
  60. Str = ""
  61. Str = CertServer.GetCertificateProperty(wszPROPSUBJECTDOT & wszPROPORGANIZATION, PROPTYPE_STRING)
  62. On Error GoTo 0
  63. If (Len(Str) <> 0) Then
  64. CertServer.SetCertificateProperty wszPROPSUBJECTDOT & wszPROPORGANIZATION, PROPTYPE_STRING, Str
  65. End If
  66. PolicyForm.OrgText.Text = Str
  67. On Error Resume Next
  68. Str = ""
  69. Str = CertServer.GetCertificateProperty(wszPROPSUBJECTDOT & wszPROPORGUNIT, PROPTYPE_STRING)
  70. On Error GoTo 0
  71. If (Len(Str) <> 0) Then
  72. CertServer.SetCertificateProperty wszPROPSUBJECTDOT & wszPROPORGUNIT, PROPTYPE_STRING, Str
  73. End If
  74. PolicyForm.OrgUnitText.Text = Str
  75. Str = "123 Main Street"
  76. CertServer.SetCertificateProperty wszPROPSUBJECTDOT & wszPROPSTREETADDRESS, PROPTYPE_STRING, Str
  77. CertServer.SetCertificateProperty wszPROPSUBJECTDOT & wszPROPSTREETADDRESS, PROPTYPE_STRING, Null
  78. CertServer.SetCertificateProperty wszPROPSUBJECTDOT & wszPROPTITLE, PROPTYPE_STRING, Null
  79. On Error Resume Next
  80. Str = ""
  81. Str = CertServer.GetCertificateProperty(wszPROPSUBJECTDOT & wszPROPLOCALITY, PROPTYPE_STRING)
  82. On Error GoTo 0
  83. If (Len(Str) <> 0) Then
  84. CertServer.SetCertificateProperty wszPROPSUBJECTDOT & wszPROPLOCALITY, PROPTYPE_STRING, Str
  85. End If
  86. PolicyForm.LocalityText.Text = Str
  87. On Error Resume Next
  88. Str = ""
  89. Str = CertServer.GetCertificateProperty(wszPROPSUBJECTDOT & wszPROPSTATE, PROPTYPE_STRING)
  90. On Error GoTo 0
  91. If (Len(Str) <> 0) Then
  92. CertServer.SetCertificateProperty wszPROPSUBJECTDOT & wszPROPSTATE, PROPTYPE_STRING, Str
  93. End If
  94. On Error Resume Next
  95. Str = ""
  96. Str = CertServer.GetCertificateProperty(wszPROPSUBJECTDOT & wszPROPCOUNTRY, PROPTYPE_STRING)
  97. On Error GoTo 0
  98. If (Len(Str) <> 0) Then
  99. CertServer.SetCertificateProperty wszPROPSUBJECTDOT & wszPROPCOUNTRY, PROPTYPE_STRING, Str
  100. End If
  101. PolicyForm.CountryText.Text = Str
  102. NotBefore = CertServer.GetCertificateProperty(wszPROPCERTIFICATENOTBEFOREDATE, PROPTYPE_DATE)
  103. PolicyForm.NotBeforeText.Text = CStr(NotBefore)
  104. NotAfter = CertServer.GetCertificateProperty(wszPROPCERTIFICATENOTAFTERDATE, PROPTYPE_DATE)
  105. PolicyForm.NotAfterText.Text = CStr(NotAfter)
  106. StringArray.Reset 3, CERT_RDN_IA5_STRING
  107. StringArray.SetValue 0, "VB Test String 1"
  108. StringArray.SetValue 1, "VB Test String 2"
  109. StringArray.SetValue 2, "VB Test String 3"
  110. Extension = StringArray.Encode
  111. CertServer.SetCertificateExtension _
  112. szOID_TEST1, _
  113. PROPTYPE_BINARY, _
  114. EXTENSION_DISABLE_FLAG, _
  115. Extension
  116. CertServer.SetCertificateExtension _
  117. szOID_TEST2, _
  118. PROPTYPE_STRING, _
  119. EXTENSION_CRITICAL_FLAG, _
  120. "http://UrlTest.htm"
  121. 'If instructed to do so, grant/deny certificates after 3 second timer expires
  122. If (Flags) Then PolicyForm.DisplayTimer.Enabled = True
  123. If (StrComp("US", PolicyForm.CountryText.Text, 1) <> 0) Then
  124. PolicyForm.StatusText.Text = "Request denied; Country/region must be US!"
  125. PolicyForm.StatusText.Font.Bold = True
  126. PolicyForm.CountryText.Font.Strikethrough = True
  127. PolicyForm.cmdIssue.Enabled = False
  128. PolicyForm.cmdPending.Enabled = False
  129. Else
  130. PolicyForm.StatusText.Text = "Request is acceptable"
  131. End If
  132. 'Display the user information and collect the response:
  133. PolicyForm.Show 1
  134. 'assume VR_INSTANT_BAD:
  135. VerifyRequest = VR_INSTANT_BAD
  136. 'if certificate was accepted or the U/I timed out, and it is acceptable,
  137. 'return VR_INSTANT_OK:
  138. If (PolicyForm.cmdIssue.Enabled) Then
  139. If (StrComp("Deny", PolicyForm.Disposition.Text) <> 0) Then
  140. If (StrComp("Pending", PolicyForm.Disposition.Text) = 0) Then
  141. VerifyRequest = VR_PENDING
  142. Else
  143. ' "TimeOut" or "Issue":
  144. VerifyRequest = VR_INSTANT_OK
  145. End If
  146. End If
  147. End If
  148. Set PolicyForm = Nothing
  149. Set CertServer = Nothing
  150. Set StringArray = Nothing
  151. End Function