// // System.Security.PermissionSet.cs // // Author: // Nick Drochak(ndrochak@gol.com) // // (C) Nick Drochak // using System; using System.Collections; using System.Security.Permissions; using System.Security; using System.Runtime.Serialization; namespace System.Security { /// Represents a collection that can contain different kinds of permissions and perform security operations. public class PermissionSet: ISecurityEncodable, ICollection, IEnumerable, IStackWalk, IDeserializationCallback { /// Constructs a new instance of the System.Security.PermissionSet class with the specified value. ///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. ///state is not a valid System.Security.Permissions.PermissionState value. public PermissionSet(PermissionState state) { if (!Enum.IsDefined(typeof(System.Security.Permissions.PermissionState), state)) { throw new System.ArgumentException(); // state is not a valid System.Security.Permissions.PermissionState value. } } /// Constructs a new instance of the System.Security.PermissionSet class with the values of the specified System.Security.PermissionSet instance. ///The System.Security.PermissionSet instance with which to initialize the values of the new instance, or null to initialize an empty permission set. ///permSet is not an instance of System.Security.PermissionSet. public PermissionSet(PermissionSet permSet) { // LAMESPEC: This would be handled by the compiler. No way permSet is not a PermissionSet. //if (false) //{ // throw new System.ArgumentException(); // permSet is not an instance of System.Security.PermissionSet. //} } /// Adds the specified System.Security.IPermission object to the current instance if that permission does not already exist in the current instance. ///The System.Security.IPermission object to add. ///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. ///perm is not a System.Security.IPermission object. public virtual IPermission AddPermission(IPermission perm) { // LAMESPEC: This would be handled by the compiler. No way perm is not an IPermission. //if (false) //{ // throw new System.ArgumentException(); // perm is not a System.Security.IPermission object. //} return null; } ///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. ///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. public virtual void Assert() { 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. } ///Returns a new System.Security.PermissionSet containing copies of the objects in the current instance. ///A new System.Security.PermissionSet that is value equal to the current instance. public virtual PermissionSet Copy() { return null; } ///Copies the permission objects in the current instance to the specified location in the specified System.Array. ///The destination System.Array. ///A System.Int32 that specifies the zero-based starting position in the array at which to begin copying. ///array has more than one dimension. ///index is outside the range of allowable values for array. ///array is null. public virtual void CopyTo(Array array, int index) { if (array.Rank > 1) { throw new System.ArgumentException("Array has more than one dimension"); // array has more than one dimension. } if (index < 0 || index >= array.Length) { throw new System.IndexOutOfRangeException(); // index is outside the range of allowable values for array. } if (null == array) { throw new System.ArgumentNullException(); // array is null. } } ///Forces a System.Security.SecurityException if all callers do not have the permissions specified by the objects contained in the current instance. ///A caller does not have the permission specified by the current instance. public virtual void Demand() { throw new System.Security.SecurityException(); // A caller does not have the permission specified by the current instance. } ///Denies access to the resources secured by the objects contained in the current instance through the code that calls this method. ///A previous call to Deny has already restricted the permissions for the current stack frame. public virtual void Deny() { throw new System.Security.SecurityException(); // A previous call to Deny has already restricted the permissions for the current stack frame. } ///Reconstructs the state of a System.Security.PermissionSet object using the specified XML encoding. ///A System.Security.SecurityElement instance containing the XML encoding to use to reconstruct the state of a System.Security.PermissionSet object. ///et is null. ///et does not contain an XML encoding for a System.Security.PermissionSet instance.An error occurred while reconstructing et. public virtual void FromXml(SecurityElement et) { if (null == et) { throw new System.ArgumentNullException("et"); // et is null. } if (true) { 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. } } /// Returns an enumerator used to iterate over the permissions in the current instance. ///A System.Collections.IEnumerator object for the permissions of the set. public virtual IEnumerator GetEnumerator() { return null; } /// Determines whether the current instance is a subset of the specified object. ///A System.Security.PermissionSet instance that is to be tested for the subset relationship. ///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. public virtual bool IsSubsetOf(PermissionSet target) { return false; } /// 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. ///A previous call to PermitOnly has already set the permissions for the current stack frame. public virtual void PermitOnly() { if (true) { throw new System.Security.SecurityException(); // A previous call to PermitOnly has already set the permissions for the current stack frame. } } /// Returns a System.String representation of the state of the current instance. ///A System.Stringcontaining the XML representation of the state of the current instance. public override string ToString() { return null; } ///Returns the XML encoding of the current instance. ///A System.Security.SecurityElement containing an XML encoding of the state of the current instance. public virtual SecurityElement ToXml() { return null; } /// Returns a System.Security.PermissionSet object that is the union of the current instance and the specified object. ///A System.Security.PermissionSet instance to be combined with the current instance. /// 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. public virtual PermissionSet Union(PermissionSet other) { return null; } ///Implemented to support the System.Collections.ICollection interface. [Note: For more information, see System.Collections.ICollection.Count.] int ICollection.Count { get { return 0; } } ///Implemented to support the System.Collections.ICollection interface. [Note: For more information, see System.Collections.ICollection.IsSynchronized.] bool ICollection.IsSynchronized { get { return false; } } ///Implemented to support the System.Collections.ICollection interface. [Note: For more information, see System.Collections.ICollection.SyncRoot.] object ICollection.SyncRoot { get { return null; } } void IDeserializationCallback.OnDeserialization(object sender){} } }