using System;
using System.Collections;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
namespace System.Net
{
/// Controls rights to access HTTP Internet resources.
// Token: 0x0200026B RID: 619
[global::System.MonoTODO("Most private members that include functionallity are not implemented!")]
[Serializable]
public sealed class WebPermission : CodeAccessPermission, IUnrestrictedPermission
{
/// Creates a new instance of the class.
// Token: 0x060016CC RID: 5836 RVA: 0x0004CC0C File Offset: 0x0004AE0C
public WebPermission()
{
}
/// Creates a new instance of the class that passes all demands or fails all demands.
/// A value.
// Token: 0x060016CD RID: 5837 RVA: 0x0004CC2C File Offset: 0x0004AE2C
public WebPermission(PermissionState state)
{
this.m_noRestriction = state == PermissionState.Unrestricted;
}
/// Initializes a new instance of the class with the specified access rights for the specified URI.
/// A NetworkAccess value that indicates what kind of access to grant to the specified URI. indicates that the application is allowed to accept connections from the Internet on a local resource. indicates that the application is allowed to connect to specific Internet resources.
/// A URI string to which access rights are granted.
///
/// is null.
// Token: 0x060016CE RID: 5838 RVA: 0x0004CC60 File Offset: 0x0004AE60
public WebPermission(NetworkAccess access, string uriString)
{
this.AddPermission(access, uriString);
}
/// Initializes a new instance of the class with the specified access rights for the specified URI regular expression.
/// A value that indicates what kind of access to grant to the specified URI. indicates that the application is allowed to accept connections from the Internet on a local resource. indicates that the application is allowed to connect to specific Internet resources.
/// A regular expression that describes the URI to which access is to be granted.
// Token: 0x060016CF RID: 5839 RVA: 0x0004CC94 File Offset: 0x0004AE94
public WebPermission(NetworkAccess access, global::System.Text.RegularExpressions.Regex uriRegex)
{
this.AddPermission(access, uriRegex);
}
/// This property returns an enumeration of a single accept permissions held by this . The possible objects types contained in the returned enumeration are and .
/// The interface that contains accept permissions.
// Token: 0x17000748 RID: 1864
// (get) Token: 0x060016D0 RID: 5840 RVA: 0x0004CCC8 File Offset: 0x0004AEC8
public IEnumerator AcceptList
{
get
{
return this.m_acceptList.GetEnumerator();
}
}
/// This property returns an enumeration of a single connect permissions held by this . The possible objects types contained in the returned enumeration are and .
/// The interface that contains connect permissions.
// Token: 0x17000749 RID: 1865
// (get) Token: 0x060016D1 RID: 5841 RVA: 0x0004CCD8 File Offset: 0x0004AED8
public IEnumerator ConnectList
{
get
{
return this.m_connectList.GetEnumerator();
}
}
/// Adds the specified URI string with the specified access rights to the current .
/// A that specifies the access rights that are granted to the URI.
/// A string that describes the URI to which access rights are granted.
///
/// is null.
// Token: 0x060016D2 RID: 5842 RVA: 0x0004CCE8 File Offset: 0x0004AEE8
public void AddPermission(NetworkAccess access, string uriString)
{
WebPermissionInfo webPermissionInfo = new WebPermissionInfo(WebPermissionInfoType.InfoString, uriString);
this.AddPermission(access, webPermissionInfo);
}
/// Adds the specified URI with the specified access rights to the current .
/// A NetworkAccess that specifies the access rights that are granted to the URI.
/// A regular expression that describes the set of URIs to which access rights are granted.
/// The parameter is null.
// Token: 0x060016D3 RID: 5843 RVA: 0x0004CD08 File Offset: 0x0004AF08
public void AddPermission(NetworkAccess access, global::System.Text.RegularExpressions.Regex uriRegex)
{
WebPermissionInfo webPermissionInfo = new WebPermissionInfo(uriRegex);
this.AddPermission(access, webPermissionInfo);
}
// Token: 0x060016D4 RID: 5844 RVA: 0x0004CD24 File Offset: 0x0004AF24
internal void AddPermission(NetworkAccess access, WebPermissionInfo info)
{
if (access != NetworkAccess.Connect)
{
if (access != NetworkAccess.Accept)
{
string text = global::Locale.GetText("Unknown NetworkAccess value {0}.");
throw new ArgumentException(string.Format(text, access), "access");
}
this.m_acceptList.Add(info);
}
else
{
this.m_connectList.Add(info);
}
}
/// Creates a copy of a .
/// A new instance of the class that has the same values as the original.
// Token: 0x060016D5 RID: 5845 RVA: 0x0004CD94 File Offset: 0x0004AF94
public override IPermission Copy()
{
return new WebPermission((!this.m_noRestriction) ? PermissionState.None : PermissionState.Unrestricted)
{
m_connectList = (ArrayList)this.m_connectList.Clone(),
m_acceptList = (ArrayList)this.m_acceptList.Clone()
};
}
/// Returns the logical intersection of two instances.
/// A new that represents the intersection of the current instance and the parameter. If the intersection is empty, the method returns null.
/// The to compare with the current instance.
///
/// is not null or of type
///
///
///
///
// Token: 0x060016D6 RID: 5846 RVA: 0x0004CDE8 File Offset: 0x0004AFE8
public override IPermission Intersect(IPermission target)
{
if (target == null)
{
return null;
}
WebPermission webPermission = target as WebPermission;
if (webPermission == null)
{
throw new ArgumentException("Argument not of type WebPermission");
}
if (this.m_noRestriction)
{
IPermission permission2;
if (this.IntersectEmpty(webPermission))
{
IPermission permission = null;
permission2 = permission;
}
else
{
permission2 = webPermission.Copy();
}
return permission2;
}
if (webPermission.m_noRestriction)
{
IPermission permission3;
if (this.IntersectEmpty(this))
{
IPermission permission = null;
permission3 = permission;
}
else
{
permission3 = this.Copy();
}
return permission3;
}
WebPermission webPermission2 = new WebPermission(PermissionState.None);
this.Intersect(this.m_connectList, webPermission.m_connectList, webPermission2.m_connectList);
this.Intersect(this.m_acceptList, webPermission.m_acceptList, webPermission2.m_acceptList);
return (!this.IntersectEmpty(webPermission2)) ? webPermission2 : null;
}
// Token: 0x060016D7 RID: 5847 RVA: 0x0004CEAC File Offset: 0x0004B0AC
private bool IntersectEmpty(WebPermission permission)
{
return !permission.m_noRestriction && permission.m_connectList.Count == 0 && permission.m_acceptList.Count == 0;
}
// Token: 0x060016D8 RID: 5848 RVA: 0x0004CEE8 File Offset: 0x0004B0E8
[global::System.MonoTODO]
private void Intersect(ArrayList list1, ArrayList list2, ArrayList result)
{
throw new NotImplementedException();
}
/// Determines whether the current is a subset of the specified object.
/// true if the current instance is a subset of the parameter; otherwise, false. If the target is null, the method returns true for an empty current permission that is not unrestricted and false otherwise.
/// The to compare to the current .
/// The target parameter is not an instance of .
/// The current instance contains a Regex-encoded right and there is not exactly the same right found in the target instance.
// Token: 0x060016D9 RID: 5849 RVA: 0x0004CEF0 File Offset: 0x0004B0F0
public override bool IsSubsetOf(IPermission target)
{
if (target == null)
{
return !this.m_noRestriction && this.m_connectList.Count == 0 && this.m_acceptList.Count == 0;
}
WebPermission webPermission = target as WebPermission;
if (webPermission == null)
{
throw new ArgumentException("Parameter target must be of type WebPermission");
}
return webPermission.m_noRestriction || (!this.m_noRestriction && ((this.m_acceptList.Count == 0 && this.m_connectList.Count == 0) || ((webPermission.m_acceptList.Count != 0 || webPermission.m_connectList.Count != 0) && this.IsSubsetOf(this.m_connectList, webPermission.m_connectList) && this.IsSubsetOf(this.m_acceptList, webPermission.m_acceptList))));
}
// Token: 0x060016DA RID: 5850 RVA: 0x0004CFD4 File Offset: 0x0004B1D4
[global::System.MonoTODO]
private bool IsSubsetOf(ArrayList list1, ArrayList list2)
{
throw new NotImplementedException();
}
/// Checks the overall permission state of the .
/// true if the was created with the ; otherwise, false.
// Token: 0x060016DB RID: 5851 RVA: 0x0004CFDC File Offset: 0x0004B1DC
public bool IsUnrestricted()
{
return this.m_noRestriction;
}
/// Creates an XML encoding of a and its current state.
/// A that contains an XML-encoded representation of the , including state information.
// Token: 0x060016DC RID: 5852 RVA: 0x0004CFE4 File Offset: 0x0004B1E4
public override SecurityElement ToXml()
{
SecurityElement securityElement = new SecurityElement("IPermission");
securityElement.AddAttribute("class", base.GetType().AssemblyQualifiedName);
securityElement.AddAttribute("version", "1");
if (this.m_noRestriction)
{
securityElement.AddAttribute("Unrestricted", "true");
return securityElement;
}
if (this.m_connectList.Count > 0)
{
this.ToXml(securityElement, "ConnectAccess", this.m_connectList.GetEnumerator());
}
if (this.m_acceptList.Count > 0)
{
this.ToXml(securityElement, "AcceptAccess", this.m_acceptList.GetEnumerator());
}
return securityElement;
}
// Token: 0x060016DD RID: 5853 RVA: 0x0004D090 File Offset: 0x0004B290
private void ToXml(SecurityElement root, string childName, IEnumerator enumerator)
{
SecurityElement securityElement = new SecurityElement(childName, null);
root.AddChild(securityElement);
while (enumerator.MoveNext())
{
object obj = enumerator.Current;
WebPermissionInfo webPermissionInfo = obj as WebPermissionInfo;
if (webPermissionInfo != null)
{
SecurityElement securityElement2 = new SecurityElement("URI");
securityElement2.AddAttribute("uri", webPermissionInfo.Info);
securityElement.AddChild(securityElement2);
}
}
}
/// Reconstructs a from an XML encoding.
/// The XML encoding from which to reconstruct the .
/// The parameter is null.
///
/// is not a permission element for this type.
///
///
///
///
// Token: 0x060016DE RID: 5854 RVA: 0x0004D0F8 File Offset: 0x0004B2F8
public override void FromXml(SecurityElement securityElement)
{
if (securityElement == null)
{
throw new ArgumentNullException("securityElement");
}
if (securityElement.Tag != "IPermission")
{
throw new ArgumentException("securityElement");
}
string text = securityElement.Attribute("Unrestricted");
if (text != null)
{
this.m_noRestriction = string.Compare(text, "true", true) == 0;
if (this.m_noRestriction)
{
return;
}
}
this.m_noRestriction = false;
this.m_connectList = new ArrayList();
this.m_acceptList = new ArrayList();
ArrayList children = securityElement.Children;
foreach (object obj in children)
{
SecurityElement securityElement2 = (SecurityElement)obj;
if (securityElement2.Tag == "ConnectAccess")
{
this.FromXml(securityElement2.Children, NetworkAccess.Connect);
}
else if (securityElement2.Tag == "AcceptAccess")
{
this.FromXml(securityElement2.Children, NetworkAccess.Accept);
}
}
}
// Token: 0x060016DF RID: 5855 RVA: 0x0004D234 File Offset: 0x0004B434
private void FromXml(ArrayList endpoints, NetworkAccess access)
{
throw new NotImplementedException();
}
/// Returns the logical union between two instances of the class.
/// A that represents the union of the current instance and the parameter. If either WebPermission is , the method returns a that is . If the target is null, the method returns a copy of the current .
/// The to combine with the current .
/// target is not null or of type .
// Token: 0x060016E0 RID: 5856 RVA: 0x0004D23C File Offset: 0x0004B43C
public override IPermission Union(IPermission target)
{
if (target == null)
{
return null;
}
WebPermission webPermission = target as WebPermission;
if (webPermission == null)
{
throw new ArgumentException("Argument not of type WebPermission");
}
if (this.m_noRestriction || webPermission.m_noRestriction)
{
return new WebPermission(PermissionState.Unrestricted);
}
WebPermission webPermission2 = (WebPermission)webPermission.Copy();
webPermission2.m_acceptList.InsertRange(webPermission2.m_acceptList.Count, this.m_acceptList);
webPermission2.m_connectList.InsertRange(webPermission2.m_connectList.Count, this.m_connectList);
return webPermission2;
}
// Token: 0x04001279 RID: 4729
private ArrayList m_acceptList = new ArrayList();
// Token: 0x0400127A RID: 4730
private ArrayList m_connectList = new ArrayList();
// Token: 0x0400127B RID: 4731
private bool m_noRestriction;
}
}