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