2
0

PublisherMembershipCondition.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. //
  2. // PublisherMembershipCondition.cs: Publisher Membership Condition
  3. //
  4. // Author:
  5. // Sebastien Pouliot ([email protected])
  6. //
  7. // (C) 2002 Motus Technologies Inc. (http://www.motus.com)
  8. //
  9. using System;
  10. using System.Security.Cryptography.X509Certificates;
  11. namespace System.Security.Policy {
  12. public sealed class PublisherMembershipCondition : IMembershipCondition, ISecurityEncodable, ISecurityPolicyEncodable {
  13. private X509Certificate x509;
  14. // LAMESPEC: Undocumented ArgumentNullException exception
  15. public PublisherMembershipCondition (X509Certificate certificate)
  16. {
  17. if (certificate == null)
  18. throw new ArgumentNullException ("certificate");
  19. // needed to match MS implementation
  20. if (certificate.GetRawCertData() == null)
  21. throw new NullReferenceException ("certificate");
  22. x509 = certificate;
  23. }
  24. public X509Certificate Certificate {
  25. get { return x509; }
  26. set {
  27. if (value == null)
  28. throw new ArgumentNullException ("value");
  29. x509 = value;
  30. }
  31. }
  32. [MonoTODO()]
  33. public bool Check (Evidence evidence)
  34. {
  35. return true;
  36. }
  37. public IMembershipCondition Copy ()
  38. {
  39. return new PublisherMembershipCondition (x509);
  40. }
  41. public override bool Equals (object o)
  42. {
  43. if (!(o is PublisherMembershipCondition))
  44. throw new ArgumentException ("not a PublisherMembershipCondition");
  45. return x509.Equals ((o as PublisherMembershipCondition).Certificate);
  46. }
  47. [MonoTODO()]
  48. public void FromXml (SecurityElement e)
  49. {
  50. }
  51. [MonoTODO()]
  52. public void FromXml (SecurityElement e, PolicyLevel level)
  53. {
  54. }
  55. public override int GetHashCode ()
  56. {
  57. return x509.GetHashCode ();
  58. }
  59. public override string ToString ()
  60. {
  61. return "Publisher - " + x509.GetPublicKeyString ();
  62. }
  63. [MonoTODO()]
  64. public SecurityElement ToXml ()
  65. {
  66. return null;
  67. }
  68. [MonoTODO()]
  69. public SecurityElement ToXml (PolicyLevel level)
  70. {
  71. return null;
  72. }
  73. }
  74. }