public override IPermission Union(IPermission target) { // LAMESPEC: according to spec we should throw an // exception when target is null. We'll follow the // behaviour of MS.Net instead of the spec, also // because it matches the Intersect behaviour. if (target == null) { return(null); } // throw new ArgumentNullException ("target"); WebPermission perm = target as WebPermission; if (perm == null) { throw new ArgumentException("Argument not of type WebPermission"); } if (this.m_noRestriction || perm.m_noRestriction) { return(new WebPermission(PermissionState.Unrestricted)); } WebPermission copy = (WebPermission)perm.Copy(); copy.m_acceptList.InsertRange(copy.m_acceptList.Count, this.m_acceptList); copy.m_connectList.InsertRange(copy.m_connectList.Count, this.m_connectList); return(copy); }
public override IPermission Intersect(IPermission target) { if (target == null) { return(null); } WebPermission perm = target as WebPermission; if (perm == null) { throw new ArgumentException("Argument not of type WebPermission"); } if (m_noRestriction) { return(IntersectEmpty(perm) ? null : perm.Copy()); } if (perm.m_noRestriction) { return(IntersectEmpty(this) ? null : this.Copy()); } WebPermission newperm = new WebPermission(PermissionState.None); Intersect(this.m_connectList, perm.m_connectList, newperm.m_connectList); Intersect(this.m_acceptList, perm.m_acceptList, newperm.m_acceptList); return(IntersectEmpty(newperm) ? null : newperm); }
/// <devdoc> /// <para>Returns the logical intersection between two <see cref='System.Net.WebPermission'/> instances.</para> /// </devdoc> public override IPermission Intersect(IPermission target) { // Pattern suggested by Security engine if (target == null) { return(null); } WebPermission other = target as WebPermission; if (other == null) { throw new ArgumentException(SR.GetString(SR.net_perm_target), "target"); } if (m_noRestriction) { return(other.Copy()); } if (other.m_noRestriction) { return(Copy()); } WebPermission result = new WebPermission(); if (m_UnrestrictedConnect && other.m_UnrestrictedConnect) { result.m_UnrestrictedConnect = true; } else if (m_UnrestrictedConnect || other.m_UnrestrictedConnect) { result.m_connectList = (ArrayList)(m_UnrestrictedConnect ? other : this).m_connectList.Clone(); } else { intersectList(m_connectList, other.m_connectList, result.m_connectList); } if (m_UnrestrictedAccept && other.m_UnrestrictedAccept) { result.m_UnrestrictedAccept = true; } else if (m_UnrestrictedAccept || other.m_UnrestrictedAccept) { result.m_acceptList = (ArrayList)(m_UnrestrictedAccept ? other : this).m_acceptList.Clone(); } else { intersectList(m_acceptList, other.m_acceptList, result.m_acceptList); } // return null if resulting permission is restricted and empty if (!result.m_UnrestrictedConnect && !result.m_UnrestrictedAccept && result.m_connectList.Count == 0 && result.m_acceptList.Count == 0) { return(null); } return(result); }
public override IPermission Intersect(IPermission target) { if (target == null) { return(null); } WebPermission permission = target as WebPermission; if (permission == null) { throw new ArgumentException(SR.GetString("net_perm_target"), "target"); } if (this.m_noRestriction) { return(permission.Copy()); } if (permission.m_noRestriction) { return(this.Copy()); } WebPermission permission2 = new WebPermission(); if (this.m_UnrestrictedConnect && permission.m_UnrestrictedConnect) { permission2.m_UnrestrictedConnect = true; } else if (this.m_UnrestrictedConnect || permission.m_UnrestrictedConnect) { permission2.m_connectList = (ArrayList)(this.m_UnrestrictedConnect ? permission : this).m_connectList.Clone(); } else { intersectList(this.m_connectList, permission.m_connectList, permission2.m_connectList); } if (this.m_UnrestrictedAccept && permission.m_UnrestrictedAccept) { permission2.m_UnrestrictedAccept = true; } else if (this.m_UnrestrictedAccept || permission.m_UnrestrictedAccept) { permission2.m_acceptList = (ArrayList)(this.m_UnrestrictedAccept ? permission : this).m_acceptList.Clone(); } else { intersectList(this.m_acceptList, permission.m_acceptList, permission2.m_acceptList); } if ((!permission2.m_UnrestrictedConnect && !permission2.m_UnrestrictedAccept) && ((permission2.m_connectList.Count == 0) && (permission2.m_acceptList.Count == 0))) { return(null); } return(permission2); }
/// <summary>Returns the logical intersection of two <see cref="T:System.Net.WebPermission" /> instances.</summary> /// <returns>A new <see cref="T:System.Net.WebPermission" /> that represents the intersection of the current instance and the <paramref name="target" /> parameter. If the intersection is empty, the method returns null.</returns> /// <param name="target">The <see cref="T:System.Net.WebPermission" /> to compare with the current instance. </param> /// <exception cref="T:System.ArgumentException"> /// <paramref name="target" /> is not null or of type <see cref="T:System.Net.WebPermission" /></exception> /// <PermissionSet> /// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" /> /// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="ControlEvidence" /> /// </PermissionSet> 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 result; if (this.IntersectEmpty(webPermission)) { IPermission permission = null; result = permission; } else { result = webPermission.Copy(); } return(result); } if (webPermission.m_noRestriction) { IPermission result2; if (this.IntersectEmpty(this)) { IPermission permission = null; result2 = permission; } else { result2 = this.Copy(); } return(result2); } 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); }
// The union of two web permissions is formed by concatenating // the list of allowed regular expressions. There is no check // for duplicates/overlaps /// <include file='doc\WebPermission.uex' path='docs/doc[@for="WebPermission.Union"]/*' /> /// <devdoc> /// <para>Returns the logical union between two <see cref='System.Net.WebPermission'/> instances.</para> /// </devdoc> public override IPermission Union(IPermission target) { // Pattern suggested by Security engine if (target == null) { return(this.Copy()); } WebPermission other = target as WebPermission; if (other == null) { throw new ArgumentException(SR.GetString(SR.net_perm_target)); } if (m_noRestriction || other.m_noRestriction) { return(new WebPermission(true)); } WebPermission result = (WebPermission)other.Copy(); for (int i = 0; i < m_connectList.Count; i++) { Regex uriPattern = m_connectList[i] as Regex; if (uriPattern == null) { result.AddPermission(NetworkAccess.Connect, m_connectList[i].ToString()); } else { result.AddPermission(NetworkAccess.Connect, uriPattern); } } for (int i = 0; i < m_acceptList.Count; i++) { Regex uriPattern = m_acceptList[i] as Regex; if (uriPattern == null) { result.AddPermission(NetworkAccess.Accept, m_acceptList[i].ToString()); } else { result.AddPermission(NetworkAccess.Accept, uriPattern); } } return(result); }
/// <include file='doc\WebPermission.uex' path='docs/doc[@for="WebPermission.Intersect"]/*' /> /// <devdoc> /// <para>Returns the logical intersection between two <see cref='System.Net.WebPermission'/> instances.</para> /// </devdoc> public override IPermission Intersect(IPermission target) { // Pattern suggested by Security engine if (target == null) { return(null); } WebPermission other = target as WebPermission; if (other == null) { throw new ArgumentException(SR.GetString(SR.net_perm_target)); } WebPermission result; if (m_noRestriction) { result = (WebPermission)(other.Copy()); } else if (other.m_noRestriction) { result = (WebPermission)(this.Copy()); } else { result = new WebPermission(false); intersectList(m_connectList, other.m_connectList, result.m_connectList); intersectList(m_acceptList, other.m_acceptList, result.m_acceptList); } // return null if resulting permission is restricted and empty if (!result.m_noRestriction && result.m_connectList.Count == 0 && result.m_acceptList.Count == 0) { return(null); } return(result); }
/// <summary>Returns the logical union between two instances of the <see cref="T:System.Net.WebPermission" /> class.</summary> /// <returns>A <see cref="T:System.Net.WebPermission" /> that represents the union of the current instance and the <paramref name="target" /> parameter. If either WebPermission is <see cref="F:System.Security.Permissions.PermissionState.Unrestricted" />, the method returns a <see cref="T:System.Net.WebPermission" /> that is <see cref="F:System.Security.Permissions.PermissionState.Unrestricted" />. If the target is null, the method returns a copy of the current <see cref="T:System.Net.WebPermission" />.</returns> /// <param name="target">The <see cref="T:System.Net.WebPermission" /> to combine with the current <see cref="T:System.Net.WebPermission" />. </param> /// <exception cref="T:System.ArgumentException">target is not null or of type <see cref="T:System.Net.WebPermission" />. </exception> 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); }