CefX509CertPrincipal.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. namespace Xilium.CefGlue
  2. {
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Diagnostics;
  6. using System.Runtime.InteropServices;
  7. using Xilium.CefGlue.Interop;
  8. /// <summary>
  9. /// Class representing the issuer or subject field of an X.509 certificate.
  10. /// </summary>
  11. public sealed unsafe partial class CefX509CertPrincipal
  12. {
  13. /// <summary>
  14. /// Returns a name that can be used to represent the issuer. It tries in this
  15. /// order: Common Name (CN), Organization Name (O) and Organizational Unit
  16. /// Name (OU) and returns the first non-empty one found.
  17. /// </summary>
  18. public string GetDisplayName()
  19. {
  20. return cef_string_userfree.ToString(
  21. cef_x509cert_principal_t.get_display_name(_self)
  22. );
  23. }
  24. /// <summary>
  25. /// Returns the common name.
  26. /// </summary>
  27. public string GetCommonName()
  28. {
  29. return cef_string_userfree.ToString(
  30. cef_x509cert_principal_t.get_common_name(_self)
  31. );
  32. }
  33. /// <summary>
  34. /// Returns the locality name.
  35. /// </summary>
  36. public string GetLocalityName()
  37. {
  38. return cef_string_userfree.ToString(
  39. cef_x509cert_principal_t.get_locality_name(_self)
  40. );
  41. }
  42. /// <summary>
  43. /// Returns the state or province name.
  44. /// </summary>
  45. public string GetStateOrProvinceName()
  46. {
  47. return cef_string_userfree.ToString(
  48. cef_x509cert_principal_t.get_state_or_province_name(_self)
  49. );
  50. }
  51. /// <summary>
  52. /// Returns the country name.
  53. /// </summary>
  54. public string GetCountryName()
  55. {
  56. return cef_string_userfree.ToString(
  57. cef_x509cert_principal_t.get_country_name(_self)
  58. );
  59. }
  60. /// <summary>
  61. /// Retrieve the list of street addresses.
  62. /// </summary>
  63. public string[] GetStreetAddresses()
  64. {
  65. cef_string_list* n_result = libcef.string_list_alloc();
  66. cef_x509cert_principal_t.get_street_addresses(_self, n_result);
  67. var result = cef_string_list.ToArray(n_result);
  68. libcef.string_list_free(n_result);
  69. return result;
  70. }
  71. /// <summary>
  72. /// Retrieve the list of organization names.
  73. /// </summary>
  74. public string[] GetOrganizationNames()
  75. {
  76. cef_string_list* n_result = libcef.string_list_alloc();
  77. cef_x509cert_principal_t.get_organization_names(_self, n_result);
  78. var result = cef_string_list.ToArray(n_result);
  79. libcef.string_list_free(n_result);
  80. return result;
  81. }
  82. /// <summary>
  83. /// Retrieve the list of organization unit names.
  84. /// </summary>
  85. public string[] GetOrganizationUnitNames()
  86. {
  87. cef_string_list* n_result = libcef.string_list_alloc();
  88. cef_x509cert_principal_t.get_organization_unit_names(_self, n_result);
  89. var result = cef_string_list.ToArray(n_result);
  90. libcef.string_list_free(n_result);
  91. return result;
  92. }
  93. /// <summary>
  94. /// Retrieve the list of domain components.
  95. /// </summary>
  96. public string[] GetDomainComponents()
  97. {
  98. cef_string_list* n_result = libcef.string_list_alloc();
  99. cef_x509cert_principal_t.get_domain_components(_self, n_result);
  100. var result = cef_string_list.ToArray(n_result);
  101. libcef.string_list_free(n_result);
  102. return result;
  103. }
  104. }
  105. }