2001-12-30 Nick Drochak <ndrochak@gol.com>
[mono.git] / mcs / class / corlib / System.Security / PermissionSet.cs
1 //\r
2 // System.Security.PermissionSet.cs\r
3 //\r
4 // Author:\r
5 //   Nick Drochak(ndrochak@gol.com)\r
6 //\r
7 // (C) Nick Drochak\r
8 //\r
9 \r
10 using System;\r
11 using System.Collections;\r
12 using System.Security.Permissions;\r
13 using System.Security;\r
14 using System.Runtime.Serialization;\r
15 \r
16 namespace System.Security\r
17 {\r
18     ///<summary> Represents a collection that can contain different kinds of permissions and perform security      operations.</summary>\r
19     public class PermissionSet: ISecurityEncodable, ICollection, IEnumerable, IStackWalk, IDeserializationCallback\r
20     {\r
21         ///<summary> Constructs a new instance of the System.Security.PermissionSet class with the   specified   value.</summary>\r
22         ///<param name="state">A System.Security.Permissions.PermissionState value. This value is either System.Security.Permissions.PermissionState.None or System.Security.Permissions.PermissionState.Unrestricted, to specify fully restricted or fully unrestricted access. </param>\r
23         ///<exception cref="System.ArgumentException">state is not a valid System.Security.Permissions.PermissionState value.</exception>\r
24         public PermissionSet(PermissionState state)\r
25         {\r
26             if (!Enum.IsDefined(typeof(System.Security.Permissions.PermissionState), state))\r
27             {\r
28                 throw new System.ArgumentException(); // state is not a valid System.Security.Permissions.PermissionState value.\r
29             }\r
30         }\r
31 \r
32         ///<summary> Constructs a new instance of the System.Security.PermissionSet class with the values of the specified System.Security.PermissionSet instance. </summary>\r
33         ///<param name="permSet">The System.Security.PermissionSet instance with which to initialize the values of the new instance, or null to initialize an empty permission set.</param>\r
34         ///<exception cref="System.ArgumentException">permSet is not an instance of System.Security.PermissionSet.</exception>\r
35         public PermissionSet(PermissionSet permSet)\r
36         {\r
37                 // LAMESPEC: This would be handled by the compiler.  No way permSet is not a PermissionSet.\r
38                 //if (false)\r
39                 //{\r
40                 //      throw new System.ArgumentException(); // permSet is not an instance of System.Security.PermissionSet.\r
41                 //}\r
42         }\r
43 \r
44         ///<summary> Adds the specified System.Security.IPermission object to   the current instance if that permission does not already exist in the current instance.</summary>\r
45         ///<param name="perm">The System.Security.IPermission object to add.</param>\r
46         ///<returns>The System.Security.IPermission is added if perm is notnull and a permission of the same type as perm does    not already exist in the current instance. If perm is null,   returns null. If a permission of the same type asperm already exists in the current instance, the union of the existing    permission and perm is added to the current instance and is returned.</returns>\r
47         ///<exception cref="System.ArgumentException">perm is not a System.Security.IPermission object.</exception>\r
48         public virtual IPermission AddPermission(IPermission perm)\r
49         {\r
50                 // LAMESPEC: This would be handled by the compiler.  No way perm is not an IPermission.\r
51                 //if (false)\r
52                 //{\r
53                 //      throw new System.ArgumentException(); // perm is not a System.Security.IPermission object.\r
54                 //}\r
55                 return null;\r
56         }\r
57 \r
58         ///<summary>Asserts that calling code can access the resources identified by the permissions contained in the current      instance through the code that calls this method, even if callers have not been      granted permission to access the resource. </summary>\r
59         ///<exception cref="System.Security.SecurityException">The asserting code does not have sufficient permission to call this method.-or-This method was called with permissions already asserted for the current stack frame.</exception>\r
60         public virtual void Assert()\r
61         {\r
62                 throw new System.Security.SecurityException(); // The asserting code does not have sufficient permission to call this method.-or-This method was called with permissions already asserted for the current stack frame.\r
63         }\r
64 \r
65         ///<summary>Returns a new System.Security.PermissionSet containing copies of the objects in the current instance.</summary>\r
66         ///<returns>A new System.Security.PermissionSet that is value equal to the current instance.</returns>\r
67         public virtual PermissionSet Copy()\r
68         {\r
69             return null;\r
70         }\r
71 \r
72         ///<summary>Copies the permission objects in the current instance to the specified      location in the specified System.Array.</summary>\r
73         ///<param name="array">The destination System.Array.</param>\r
74         ///<param name="index">A System.Int32 that specifies the zero-based starting position in the array at which to begin copying.</param>\r
75         ///<exception cref="System.ArgumentException">array has more than one dimension.</exception>\r
76         ///<exception cref="System.IndexOutOfRangeException">index is outside the range of allowable values for array.</exception>\r
77         ///<exception cref="System.ArgumentNullException">array is null.</exception>\r
78         public virtual void CopyTo(Array array, int index)\r
79         {\r
80             if (array.Rank > 1)\r
81             {\r
82                 throw new System.ArgumentException("Array has more than one dimension"); // array has more than one dimension.\r
83             }\r
84             if (index < 0 || index >= array.Length)\r
85             {\r
86                 throw new System.IndexOutOfRangeException(); // index is outside the range of allowable values for array.\r
87             }\r
88             if (null == array)\r
89             {\r
90                 throw new System.ArgumentNullException(); // array is null.\r
91             }\r
92         }\r
93 \r
94         ///<summary>Forces a System.Security.SecurityException if all callers do    not have the permissions specified by the objects   contained in the current instance.</summary>\r
95         ///<exception cref="System.Security.SecurityException">A caller does not have the permission specified by the current instance.</exception>\r
96         public virtual void Demand()\r
97         {\r
98                 throw new System.Security.SecurityException(); // A caller does not have the permission specified by the current instance.\r
99         }\r
100 \r
101         ///<summary>Denies access to the resources secured by the objects contained in the current instance through the      code that calls this method.</summary>\r
102         ///<exception cref="System.Security.SecurityException">A previous call to Deny has already restricted the permissions for the current stack frame.</exception>\r
103         public virtual void Deny()\r
104         {\r
105                 throw new System.Security.SecurityException(); // A previous call to Deny has already restricted the permissions for the current stack frame.\r
106         }\r
107 \r
108         ///<summary>Reconstructs the state of a System.Security.PermissionSet object using the specified XML   encoding.</summary>\r
109         ///<param name="et">A System.Security.SecurityElement instance containing the XML encoding to use to reconstruct the state of a System.Security.PermissionSet object.</param>\r
110         ///<exception cref="System.ArgumentNullException">et is null.</exception>\r
111         ///<exception cref="System.ArgumentException">et does not contain an XML encoding for a System.Security.PermissionSet instance.An error occurred while reconstructing et.</exception>\r
112         public virtual void FromXml(SecurityElement et)\r
113         {\r
114             if (null == et)\r
115             {\r
116                 throw new System.ArgumentNullException("et"); // et is null.\r
117             }\r
118             if (true)\r
119             {\r
120                 throw new System.ArgumentException("et does not contain an XML encoding for a System.Security.PermissionSet instance."); // et does not contain an XML encoding for a System.Security.PermissionSet instance.An error occurred while reconstructing et.\r
121             }\r
122         }\r
123 \r
124         ///<summary> Returns an enumerator used to iterate      over the permissions in the current instance.</summary>\r
125         ///<returns>A System.Collections.IEnumerator object   for the permissions of the   set.</returns>\r
126         public virtual IEnumerator GetEnumerator()\r
127         {\r
128             return null;\r
129         }\r
130 \r
131         ///<summary> Determines whether the current instance is a subset of      the specified object.</summary>\r
132         ///<param name="target">A System.Security.PermissionSet instance that is to be tested for the subset relationship. </param>\r
133         ///<returns>true if the current instance is a subset of target;   otherwise, false. If the current instance is unrestricted, andtarget is not, returns false. If target is    unrestricted, returns true.</returns>\r
134         public virtual bool IsSubsetOf(PermissionSet target)\r
135         {\r
136             return false;\r
137         }\r
138 \r
139         ///<summary> Specifies that only the resources described by the current      instance can be accessed by calling code, even if the code has      been granted permission to access other resources.</summary>\r
140         ///<exception cref="System.Security.SecurityException">A previous call to PermitOnly has already set the permissions for the current stack frame.</exception>\r
141         public virtual void PermitOnly()\r
142         {\r
143             if (true)\r
144             {\r
145                 throw new System.Security.SecurityException(); // A previous call to PermitOnly has already set the permissions for the current stack frame.\r
146             }\r
147         }\r
148 \r
149         ///<summary> Returns a System.String representation of the state   of the current instance.</summary>\r
150         ///<returns>A System.Stringcontaining the XML representation of the state of the current instance.</returns>\r
151         public override string ToString()\r
152         {\r
153             return null;\r
154         }\r
155 \r
156         ///<summary>Returns the XML encoding of the current instance.</summary>\r
157         ///<returns>A System.Security.SecurityElement containing an XML encoding of the state of the   current instance.</returns>\r
158         public virtual SecurityElement ToXml()\r
159         {\r
160             return null;\r
161         }\r
162 \r
163         ///<summary> Returns a System.Security.PermissionSet object that is the union of the current instance and   the specified object.</summary>\r
164         ///<param name="other">A System.Security.PermissionSet instance to be combined with the current instance.</param>\r
165         ///<returns> A new System.Security.PermissionSet instance that represents the   union of the current instance and other. If the current   instance or other is unrestricted, returns a System.Security.PermissionSet   instance that is unrestricted.</returns>\r
166         public virtual PermissionSet Union(PermissionSet other)\r
167         {\r
168             return null;\r
169         }\r
170 \r
171         ///<summary>Implemented to support the System.Collections.ICollection interface. [Note: For more information, see System.Collections.ICollection.Count.]</summary>\r
172         int ICollection.Count \r
173         {\r
174             get\r
175             {\r
176                 return 0;\r
177             }\r
178         }\r
179 \r
180         ///<summary>Implemented to support the System.Collections.ICollection interface. [Note: For more information, see System.Collections.ICollection.IsSynchronized.]</summary>\r
181         bool ICollection.IsSynchronized \r
182         {\r
183             get\r
184             {\r
185                 return false;\r
186             }\r
187         }\r
188 \r
189         ///<summary>Implemented to support the System.Collections.ICollection interface. [Note: For more information, see System.Collections.ICollection.SyncRoot.]</summary>\r
190         object ICollection.SyncRoot \r
191         {\r
192             get\r
193             {\r
194                 return null;\r
195             }\r
196         }\r
197 \r
198         void IDeserializationCallback.OnDeserialization(object sender){}\r
199 \r
200     }\r
201 }\r