using System; using System.Runtime.InteropServices; namespace System.Security.Permissions { /// Controls the ability to access key containers. This class cannot be inherited. // Token: 0x02000554 RID: 1364 [ComVisible(true)] [Serializable] public sealed class KeyContainerPermission : CodeAccessPermission, IBuiltInPermission, IUnrestrictedPermission { /// Initializes a new instance of the class with either restricted or unrestricted permission. /// One of the values. /// /// is not a valid value. // Token: 0x060031C8 RID: 12744 RVA: 0x000AB2B0 File Offset: 0x000A94B0 public KeyContainerPermission(PermissionState state) { if (CodeAccessPermission.CheckPermissionState(state, true) == PermissionState.Unrestricted) { this._flags = KeyContainerPermissionFlags.AllFlags; } } /// Initializes a new instance of the class with the specified access. /// A bitwise combination of the values. /// /// is not a valid combination of the values. // Token: 0x060031C9 RID: 12745 RVA: 0x000AB2D0 File Offset: 0x000A94D0 public KeyContainerPermission(KeyContainerPermissionFlags flags) { this.SetFlags(flags); } /// Initializes a new instance of the class with the specified global access and specific key container access rights. /// A bitwise combination of the values. /// An array of objects identifying specific key container access rights. /// /// is not a valid combination of the values. /// /// is null. // Token: 0x060031CA RID: 12746 RVA: 0x000AB2E0 File Offset: 0x000A94E0 public KeyContainerPermission(KeyContainerPermissionFlags flags, KeyContainerPermissionAccessEntry[] accessList) { this.SetFlags(flags); if (accessList != null) { foreach (KeyContainerPermissionAccessEntry keyContainerPermissionAccessEntry in accessList) { this._accessEntries.Add(keyContainerPermissionAccessEntry); } } } // Token: 0x060031CB RID: 12747 RVA: 0x000AB328 File Offset: 0x000A9528 int IBuiltInPermission.GetTokenIndex() { return 16; } /// Gets the collection of objects associated with the current permission. /// A containing the objects for this . // Token: 0x170009BE RID: 2494 // (get) Token: 0x060031CC RID: 12748 RVA: 0x000AB32C File Offset: 0x000A952C public KeyContainerPermissionAccessEntryCollection AccessEntries { get { return this._accessEntries; } } /// Gets the key container permission flags that apply to all key containers associated with the permission. /// A bitwise combination of the values. // Token: 0x170009BF RID: 2495 // (get) Token: 0x060031CD RID: 12749 RVA: 0x000AB334 File Offset: 0x000A9534 public KeyContainerPermissionFlags Flags { get { return this._flags; } } /// Creates and returns an identical copy of the current permission. /// A copy of the current permission. // Token: 0x060031CE RID: 12750 RVA: 0x000AB33C File Offset: 0x000A953C public override IPermission Copy() { if (this._accessEntries.Count == 0) { return new KeyContainerPermission(this._flags); } KeyContainerPermissionAccessEntry[] array = new KeyContainerPermissionAccessEntry[this._accessEntries.Count]; this._accessEntries.CopyTo(array, 0); return new KeyContainerPermission(this._flags, array); } /// Reconstructs a permission with a specified state from an XML encoding. /// A that contains the XML encoding used to reconstruct the permission. /// /// is null. /// /// is not a valid permission element.-or- The version number of is not supported. // Token: 0x060031CF RID: 12751 RVA: 0x000AB390 File Offset: 0x000A9590 [MonoTODO("(2.0) missing support for AccessEntries")] public override void FromXml(SecurityElement securityElement) { CodeAccessPermission.CheckSecurityElement(securityElement, "securityElement", 1, 1); if (CodeAccessPermission.IsUnrestricted(securityElement)) { this._flags = KeyContainerPermissionFlags.AllFlags; } else { this._flags = (KeyContainerPermissionFlags)((int)Enum.Parse(typeof(KeyContainerPermissionFlags), securityElement.Attribute("Flags"))); } } /// Creates and returns a permission that is the intersection of the current permission and the specified permission. /// A new permission that represents the intersection of the current permission and the specified permission. This new permission is null if the intersection is empty. /// A permission to intersect with the current permission. It must be the same type as the current permission. /// /// is not null and does not specify a permission of the same type as the current permission. // Token: 0x060031D0 RID: 12752 RVA: 0x000AB3EC File Offset: 0x000A95EC [MonoTODO("(2.0)")] public override IPermission Intersect(IPermission target) { return null; } /// Determines whether the current permission is a subset of the specified permission. /// true if the current permission is a subset of the specified permission; otherwise, false. /// A permission to test for the subset relationship. This permission must be the same type as the current permission. /// /// is not null and does not specify a permission of the same type as the current permission. // Token: 0x060031D1 RID: 12753 RVA: 0x000AB3F0 File Offset: 0x000A95F0 [MonoTODO("(2.0)")] public override bool IsSubsetOf(IPermission target) { return false; } /// Determines whether the current permission is unrestricted. /// true if the current permission is unrestricted; otherwise, false. // Token: 0x060031D2 RID: 12754 RVA: 0x000AB3F4 File Offset: 0x000A95F4 public bool IsUnrestricted() { return this._flags == KeyContainerPermissionFlags.AllFlags; } /// Creates an XML encoding of the permission and its current state. /// A that contains an XML encoding of the permission, including state information. // Token: 0x060031D3 RID: 12755 RVA: 0x000AB404 File Offset: 0x000A9604 [MonoTODO("(2.0) missing support for AccessEntries")] public override SecurityElement ToXml() { SecurityElement securityElement = base.Element(1); if (this.IsUnrestricted()) { securityElement.AddAttribute("Unrestricted", "true"); } return securityElement; } /// Creates a permission that is the union of the current permission and the specified permission. /// A new permission that represents the union of the current permission and the specified permission. /// A permission to combine with the current permission. It must be of the same type as the current permission. /// /// is not null and does not specify a permission of the same type as the current permission. // Token: 0x060031D4 RID: 12756 RVA: 0x000AB43C File Offset: 0x000A963C public override IPermission Union(IPermission target) { KeyContainerPermission keyContainerPermission = this.Cast(target); if (keyContainerPermission == null) { return this.Copy(); } KeyContainerPermissionAccessEntryCollection keyContainerPermissionAccessEntryCollection = new KeyContainerPermissionAccessEntryCollection(); foreach (KeyContainerPermissionAccessEntry keyContainerPermissionAccessEntry in this._accessEntries) { keyContainerPermissionAccessEntryCollection.Add(keyContainerPermissionAccessEntry); } foreach (KeyContainerPermissionAccessEntry keyContainerPermissionAccessEntry2 in keyContainerPermission._accessEntries) { if (this._accessEntries.IndexOf(keyContainerPermissionAccessEntry2) == -1) { keyContainerPermissionAccessEntryCollection.Add(keyContainerPermissionAccessEntry2); } } if (keyContainerPermissionAccessEntryCollection.Count == 0) { return new KeyContainerPermission(this._flags | keyContainerPermission._flags); } KeyContainerPermissionAccessEntry[] array = new KeyContainerPermissionAccessEntry[keyContainerPermissionAccessEntryCollection.Count]; keyContainerPermissionAccessEntryCollection.CopyTo(array, 0); return new KeyContainerPermission(this._flags | keyContainerPermission._flags, array); } // Token: 0x060031D5 RID: 12757 RVA: 0x000AB51C File Offset: 0x000A971C private void SetFlags(KeyContainerPermissionFlags flags) { if ((flags & KeyContainerPermissionFlags.AllFlags) != KeyContainerPermissionFlags.NoFlags) { string text = string.Format(Locale.GetText("Invalid enum {0}"), flags); throw new ArgumentException(text, "KeyContainerPermissionFlags"); } this._flags = flags; } // Token: 0x060031D6 RID: 12758 RVA: 0x000AB560 File Offset: 0x000A9760 private KeyContainerPermission Cast(IPermission target) { if (target == null) { return null; } KeyContainerPermission keyContainerPermission = target as KeyContainerPermission; if (keyContainerPermission == null) { CodeAccessPermission.ThrowInvalidPermission(target, typeof(KeyContainerPermission)); } return keyContainerPermission; } // Token: 0x04001471 RID: 5233 private const int version = 1; // Token: 0x04001472 RID: 5234 private KeyContainerPermissionAccessEntryCollection _accessEntries; // Token: 0x04001473 RID: 5235 private KeyContainerPermissionFlags _flags; } }