scripts
This commit is contained in:
@@ -0,0 +1,227 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Permissions;
|
||||
|
||||
namespace System.Security.Policy
|
||||
{
|
||||
/// <summary>Represents the statement of a <see cref="T:System.Security.Policy.CodeGroup" /> describing the permissions and other information that apply to code with a particular set of evidence. This class cannot be inherited.</summary>
|
||||
// Token: 0x0200059A RID: 1434
|
||||
[ComVisible(true)]
|
||||
[Serializable]
|
||||
public sealed class PolicyStatement : ISecurityEncodable, ISecurityPolicyEncodable
|
||||
{
|
||||
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Policy.PolicyStatement" /> class with the specified <see cref="T:System.Security.PermissionSet" />.</summary>
|
||||
/// <param name="permSet">The <see cref="T:System.Security.PermissionSet" /> with which to initialize the new instance. </param>
|
||||
// Token: 0x06003470 RID: 13424 RVA: 0x000B50DC File Offset: 0x000B32DC
|
||||
public PolicyStatement(PermissionSet permSet)
|
||||
: this(permSet, PolicyStatementAttribute.Nothing)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>Initializes a new instance of the <see cref="T:System.Security.Policy.PolicyStatement" /> class with the specified <see cref="T:System.Security.PermissionSet" /> and attributes.</summary>
|
||||
/// <param name="permSet">The <see cref="T:System.Security.PermissionSet" /> with which to initialize the new instance. </param>
|
||||
/// <param name="attributes">A bitwise combination of the <see cref="T:System.Security.Policy.PolicyStatementAttribute" /> values. </param>
|
||||
// Token: 0x06003471 RID: 13425 RVA: 0x000B50E8 File Offset: 0x000B32E8
|
||||
public PolicyStatement(PermissionSet permSet, PolicyStatementAttribute attributes)
|
||||
{
|
||||
if (permSet != null)
|
||||
{
|
||||
this.perms = permSet.Copy();
|
||||
this.perms.SetReadOnly(true);
|
||||
}
|
||||
this.attrs = attributes;
|
||||
}
|
||||
|
||||
/// <summary>Gets or sets the <see cref="T:System.Security.PermissionSet" /> of the policy statement.</summary>
|
||||
/// <returns>The <see cref="T:System.Security.PermissionSet" /> of the policy statement.</returns>
|
||||
// Token: 0x17000A4E RID: 2638
|
||||
// (get) Token: 0x06003472 RID: 13426 RVA: 0x000B5120 File Offset: 0x000B3320
|
||||
// (set) Token: 0x06003473 RID: 13427 RVA: 0x000B514C File Offset: 0x000B334C
|
||||
public PermissionSet PermissionSet
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.perms == null)
|
||||
{
|
||||
this.perms = new PermissionSet(PermissionState.None);
|
||||
this.perms.SetReadOnly(true);
|
||||
}
|
||||
return this.perms;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.perms = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Gets or sets the attributes of the policy statement.</summary>
|
||||
/// <returns>The attributes of the policy statement.</returns>
|
||||
// Token: 0x17000A4F RID: 2639
|
||||
// (get) Token: 0x06003474 RID: 13428 RVA: 0x000B5158 File Offset: 0x000B3358
|
||||
// (set) Token: 0x06003475 RID: 13429 RVA: 0x000B5160 File Offset: 0x000B3360
|
||||
public PolicyStatementAttribute Attributes
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.attrs;
|
||||
}
|
||||
set
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case PolicyStatementAttribute.Nothing:
|
||||
case PolicyStatementAttribute.Exclusive:
|
||||
case PolicyStatementAttribute.LevelFinal:
|
||||
case PolicyStatementAttribute.All:
|
||||
this.attrs = value;
|
||||
return;
|
||||
default:
|
||||
{
|
||||
string text = Locale.GetText("Invalid value for {0}.");
|
||||
throw new ArgumentException(string.Format(text, "PolicyStatementAttribute"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Gets a string representation of the attributes of the policy statement.</summary>
|
||||
/// <returns>A text string representing the attributes of the policy statement.</returns>
|
||||
// Token: 0x17000A50 RID: 2640
|
||||
// (get) Token: 0x06003476 RID: 13430 RVA: 0x000B51B4 File Offset: 0x000B33B4
|
||||
public string AttributeString
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (this.attrs)
|
||||
{
|
||||
case PolicyStatementAttribute.Exclusive:
|
||||
return "Exclusive";
|
||||
case PolicyStatementAttribute.LevelFinal:
|
||||
return "LevelFinal";
|
||||
case PolicyStatementAttribute.All:
|
||||
return "Exclusive LevelFinal";
|
||||
default:
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Creates an equivalent copy of the current policy statement.</summary>
|
||||
/// <returns>A new copy of the <see cref="T:System.Security.Policy.PolicyStatement" /> with <see cref="P:System.Security.Policy.PolicyStatement.PermissionSet" /> and <see cref="P:System.Security.Policy.PolicyStatement.Attributes" /> identical to those of the current <see cref="T:System.Security.Policy.PolicyStatement" />.</returns>
|
||||
// Token: 0x06003477 RID: 13431 RVA: 0x000B51F8 File Offset: 0x000B33F8
|
||||
public PolicyStatement Copy()
|
||||
{
|
||||
return new PolicyStatement(this.perms, this.attrs);
|
||||
}
|
||||
|
||||
/// <summary>Reconstructs a security object with a given state from an XML encoding.</summary>
|
||||
/// <param name="et">The XML encoding to use to reconstruct the security object. </param>
|
||||
/// <exception cref="T:System.ArgumentNullException">The <paramref name="et" /> parameter is null. </exception>
|
||||
/// <exception cref="T:System.ArgumentException">The <paramref name="et" /> parameter is not a valid <see cref="T:System.Security.Policy.PolicyStatement" /> encoding. </exception>
|
||||
/// <PermissionSet>
|
||||
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ControlEvidence" />
|
||||
/// </PermissionSet>
|
||||
// Token: 0x06003478 RID: 13432 RVA: 0x000B520C File Offset: 0x000B340C
|
||||
public void FromXml(SecurityElement et)
|
||||
{
|
||||
this.FromXml(et, null);
|
||||
}
|
||||
|
||||
/// <summary>Reconstructs a security object with a given state from an XML encoding.</summary>
|
||||
/// <param name="et">The XML encoding to use to reconstruct the security object. </param>
|
||||
/// <param name="level">The <see cref="T:System.Security.Policy.PolicyLevel" /> context for lookup of <see cref="T:System.Security.NamedPermissionSet" /> values. </param>
|
||||
/// <exception cref="T:System.ArgumentNullException">The <paramref name="et" /> parameter is null. </exception>
|
||||
/// <exception cref="T:System.ArgumentException">The <paramref name="et" /> parameter is not a valid <see cref="T:System.Security.Policy.PolicyStatement" /> encoding. </exception>
|
||||
/// <PermissionSet>
|
||||
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ControlEvidence" />
|
||||
/// </PermissionSet>
|
||||
// Token: 0x06003479 RID: 13433 RVA: 0x000B5218 File Offset: 0x000B3418
|
||||
public void FromXml(SecurityElement et, PolicyLevel level)
|
||||
{
|
||||
if (et == null)
|
||||
{
|
||||
throw new ArgumentNullException("et");
|
||||
}
|
||||
if (et.Tag != "PolicyStatement")
|
||||
{
|
||||
throw new ArgumentException(Locale.GetText("Invalid tag."));
|
||||
}
|
||||
string text = et.Attribute("Attributes");
|
||||
if (text != null)
|
||||
{
|
||||
this.attrs = (PolicyStatementAttribute)((int)Enum.Parse(typeof(PolicyStatementAttribute), text));
|
||||
}
|
||||
SecurityElement securityElement = et.SearchForChildByTag("PermissionSet");
|
||||
this.PermissionSet.FromXml(securityElement);
|
||||
}
|
||||
|
||||
/// <summary>Creates an XML encoding of the security object and its current state.</summary>
|
||||
/// <returns>An XML encoding of the security object, including any state information.</returns>
|
||||
/// <PermissionSet>
|
||||
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
|
||||
/// </PermissionSet>
|
||||
// Token: 0x0600347A RID: 13434 RVA: 0x000B52A0 File Offset: 0x000B34A0
|
||||
public SecurityElement ToXml()
|
||||
{
|
||||
return this.ToXml(null);
|
||||
}
|
||||
|
||||
/// <summary>Creates an XML encoding of the security object and its current state.</summary>
|
||||
/// <returns>An XML encoding of the security object, including any state information.</returns>
|
||||
/// <param name="level">The <see cref="T:System.Security.Policy.PolicyLevel" /> context for lookup of <see cref="T:System.Security.NamedPermissionSet" /> values. </param>
|
||||
/// <PermissionSet>
|
||||
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
|
||||
/// </PermissionSet>
|
||||
// Token: 0x0600347B RID: 13435 RVA: 0x000B52AC File Offset: 0x000B34AC
|
||||
public SecurityElement ToXml(PolicyLevel level)
|
||||
{
|
||||
SecurityElement securityElement = new SecurityElement("PolicyStatement");
|
||||
securityElement.AddAttribute("version", "1");
|
||||
if (this.attrs != PolicyStatementAttribute.Nothing)
|
||||
{
|
||||
securityElement.AddAttribute("Attributes", this.attrs.ToString());
|
||||
}
|
||||
securityElement.AddChild(this.PermissionSet.ToXml());
|
||||
return securityElement;
|
||||
}
|
||||
|
||||
/// <summary>Determines whether the specified <see cref="T:System.Security.Policy.PolicyStatement" /> object is equal to the current <see cref="T:System.Security.Policy.PolicyStatement" />.</summary>
|
||||
/// <returns>true if the specified <see cref="T:System.Security.Policy.PolicyStatement" /> is equal to the current <see cref="T:System.Security.Policy.PolicyStatement" /> object; otherwise, false.</returns>
|
||||
/// <param name="obj">The <see cref="T:System.Security.Policy.PolicyStatement" /> object to compare with the current <see cref="T:System.Security.Policy.PolicyStatement" />. </param>
|
||||
// Token: 0x0600347C RID: 13436 RVA: 0x000B530C File Offset: 0x000B350C
|
||||
[ComVisible(false)]
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
PolicyStatement policyStatement = obj as PolicyStatement;
|
||||
return policyStatement != null && this.PermissionSet.Equals(obj) && this.attrs == policyStatement.attrs;
|
||||
}
|
||||
|
||||
/// <summary>Gets a hash code for the <see cref="T:System.Security.Policy.PolicyStatement" /> object that is suitable for use in hashing algorithms and data structures such as a hash table.</summary>
|
||||
/// <returns>A hash code for the current <see cref="T:System.Security.Policy.PolicyStatement" /> object.</returns>
|
||||
/// <PermissionSet>
|
||||
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
|
||||
/// </PermissionSet>
|
||||
// Token: 0x0600347D RID: 13437 RVA: 0x000B5354 File Offset: 0x000B3554
|
||||
[ComVisible(false)]
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return this.PermissionSet.GetHashCode() ^ (int)this.attrs;
|
||||
}
|
||||
|
||||
// Token: 0x0600347E RID: 13438 RVA: 0x000B5368 File Offset: 0x000B3568
|
||||
internal static PolicyStatement Empty()
|
||||
{
|
||||
return new PolicyStatement(new PermissionSet(PermissionState.None));
|
||||
}
|
||||
|
||||
// Token: 0x04001569 RID: 5481
|
||||
private PermissionSet perms;
|
||||
|
||||
// Token: 0x0400156A RID: 5482
|
||||
private PolicyStatementAttribute attrs;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user