private PolicyStatement CalculateAssemblyPolicy(Evidence evidence) { PolicyStatement thisPolicy = null; Url url = evidence.GetHostEvidence <Url>(); if (url != null) { thisPolicy = CalculatePolicy(url.GetURLString().Host, url.GetURLString().Scheme, url.GetURLString().Port); } if (thisPolicy == null) { Site site = evidence.GetHostEvidence <Site>(); if (site != null) { thisPolicy = CalculatePolicy(site.Name, null, null); } } if (thisPolicy == null) { thisPolicy = new PolicyStatement(new PermissionSet(false), PolicyStatementAttribute.Nothing); } return(thisPolicy); }
internal PolicyStatement InternalResolve(Evidence evidence) { if (evidence == null) { throw new ArgumentNullException("evidence"); } if (this.MembershipCondition.Check(evidence)) { IEnumerator evidenceEnumerator = evidence.GetHostEnumerator(); PolicyStatement thisPolicy = null; Site site = null; while (evidenceEnumerator.MoveNext()) { Url url = evidenceEnumerator.Current as Url; if (url != null) { thisPolicy = CalculatePolicy(url.GetURLString().Host, url.GetURLString().Scheme); } else { if (site == null) { site = evidenceEnumerator.Current as Site; } } } if (thisPolicy == null && site != null) { thisPolicy = CalculatePolicy(site.Name, null); } if (thisPolicy == null) { thisPolicy = new PolicyStatement(new PermissionSet(false), PolicyStatementAttribute.Nothing); } return(thisPolicy); } return(null); }
bool IReportMatchMembershipCondition.Check(Evidence evidence, out object usedEvidence) { usedEvidence = null; if (evidence == null) { return(false); } Url url = evidence.GetHostEvidence <Url>(); if (url != null) { if (m_url == null && m_element != null) { ParseURL(); } if (url.GetURLString().IsSubsetOf(m_url)) { usedEvidence = url; return(true); } } return(false); }
bool IReportMatchMembershipCondition.Check(Evidence evidence, out object usedEvidence) { usedEvidence = null; if (evidence != null) { ApplicationDirectory hostEvidence = evidence.GetHostEvidence <ApplicationDirectory>(); Url url = evidence.GetHostEvidence <Url>(); if ((hostEvidence != null) && (url != null)) { string directory = hostEvidence.Directory; if ((directory != null) && (directory.Length > 1)) { if (directory[directory.Length - 1] == '/') { directory = directory + "*"; } else { directory = directory + "/*"; } URLString operand = new URLString(directory); if (url.GetURLString().IsSubsetOf(operand)) { usedEvidence = hostEvidence; return(true); } } } } return(false); }
public SecurityException(string message, AssemblyName assemblyName, PermissionSet grant, PermissionSet refused, MethodInfo method, SecurityAction action, object demanded, IPermission permThatFailed, Evidence evidence) : base(message) { PermissionSet.s_fullTrust.Assert(); this.SetErrorCode(-2146233078); this.Action = action; if (permThatFailed != null) { this.m_typeOfPermissionThatFailed = permThatFailed.GetType(); } this.FirstPermissionThatFailed = permThatFailed; this.Demanded = demanded; this.m_granted = grant == null ? "" : grant.ToXml().ToString(); this.m_refused = refused == null ? "" : refused.ToXml().ToString(); this.m_denied = ""; this.m_permitOnly = ""; this.m_assemblyName = assemblyName; this.Method = method; this.m_url = ""; this.m_zone = SecurityZone.NoZone; if (evidence != null) { System.Security.Policy.Url hostEvidence1 = evidence.GetHostEvidence <System.Security.Policy.Url>(); if (hostEvidence1 != null) { this.m_url = hostEvidence1.GetURLString().ToString(); } System.Security.Policy.Zone hostEvidence2 = evidence.GetHostEvidence <System.Security.Policy.Zone>(); if (hostEvidence2 != null) { this.m_zone = hostEvidence2.SecurityZone; } } this.m_debugString = this.ToString(true, false); }
// Token: 0x06002855 RID: 10325 RVA: 0x0009465C File Offset: 0x0009285C bool IReportMatchMembershipCondition.Check(Evidence evidence, out object usedEvidence) { usedEvidence = null; if (evidence == null) { return(false); } ApplicationDirectory hostEvidence = evidence.GetHostEvidence <ApplicationDirectory>(); Url hostEvidence2 = evidence.GetHostEvidence <Url>(); if (hostEvidence != null && hostEvidence2 != null) { string text = hostEvidence.Directory; if (text != null && text.Length > 1) { if (text[text.Length - 1] == '/') { text += "*"; } else { text += "/*"; } URLString operand = new URLString(text); if (hostEvidence2.GetURLString().IsSubsetOf(operand)) { usedEvidence = hostEvidence; return(true); } } } return(false); }
bool IReportMatchMembershipCondition.Check(Evidence evidence, out object usedEvidence) { usedEvidence = (object)null; if (evidence == null) { return(false); } ApplicationDirectory hostEvidence1 = evidence.GetHostEvidence <ApplicationDirectory>(); Url hostEvidence2 = evidence.GetHostEvidence <Url>(); if (hostEvidence1 != null && hostEvidence2 != null) { string directory = hostEvidence1.Directory; if (directory != null && directory.Length > 1) { string str = directory; int index = str.Length - 1; URLString urlString = new URLString((int)str[index] != 47 ? directory + "/*" : directory + "*"); if (hostEvidence2.GetURLString().IsSubsetOf((SiteString)urlString)) { usedEvidence = (object)hostEvidence1; return(true); } } } return(false); }
internal PolicyStatement CalculatePolicy(Url url) { URLString uRLString = url.GetURLString(); if (string.Compare(uRLString.Scheme, "file", StringComparison.OrdinalIgnoreCase) != 0) { return null; } string directoryName = uRLString.GetDirectoryName(); PermissionSet permSet = new PermissionSet(PermissionState.None); permSet.SetPermission(new FileIOPermission(this.m_access, Path.GetFullPath(directoryName))); return new PolicyStatement(permSet, PolicyStatementAttribute.Nothing); }
internal PolicyStatement CalculatePolicy(Url url) { URLString uRLString = url.GetURLString(); if (string.Compare(uRLString.Scheme, "file", StringComparison.OrdinalIgnoreCase) != 0) { return(null); } string directoryName = uRLString.GetDirectoryName(); PermissionSet permSet = new PermissionSet(PermissionState.None); permSet.SetPermission(new FileIOPermission(this.m_access, Path.GetFullPath(directoryName))); return(new PolicyStatement(permSet, PolicyStatementAttribute.Nothing)); }
private PolicyStatement CalculateAssemblyPolicy(Evidence evidence) { PolicyStatement statement = null; Url hostEvidence = evidence.GetHostEvidence <Url>(); if (hostEvidence != null) { statement = this.CalculatePolicy(hostEvidence.GetURLString().Host, hostEvidence.GetURLString().Scheme, hostEvidence.GetURLString().Port); } else { Site site = evidence.GetHostEvidence <Site>(); if (site != null) { statement = this.CalculatePolicy(site.Name, null, null); } } if (statement == null) { statement = new PolicyStatement(new PermissionSet(false), PolicyStatementAttribute.Nothing); } return(statement); }
private PolicyStatement CalculateAssemblyPolicy(Evidence evidence) { IEnumerator evidenceEnumerator = evidence.GetHostEnumerator(); PolicyStatement thisPolicy = null; Site site = null; while (evidenceEnumerator.MoveNext()) { Url url = evidenceEnumerator.Current as Url; if (url != null) { thisPolicy = CalculatePolicy(url.GetURLString().Host, url.GetURLString().Scheme, url.GetURLString().Port); } else { if (site == null) { site = evidenceEnumerator.Current as Site; } } } if (thisPolicy == null && site != null) { thisPolicy = CalculatePolicy(site.Name, null, null); } if (thisPolicy == null) { thisPolicy = new PolicyStatement(new PermissionSet(false), PolicyStatementAttribute.Nothing); } return(thisPolicy); }
private PolicyStatement CalculatePolicy(Url url) { URLString urlString = url.GetURLString(); if (String.Compare(urlString.Scheme, "file", true, CultureInfo.InvariantCulture) != 0) { return(null); } String directory = urlString.GetDirectoryName(); PermissionSet permSet = new PermissionSet(PermissionState.None); permSet.SetPermission(new FileIOPermission(m_access, directory)); return(new PolicyStatement(permSet, PolicyStatementAttribute.Nothing)); }
bool IReportMatchMembershipCondition.Check(Evidence evidence, out object usedEvidence) { usedEvidence = null; if (evidence == null) { return(false); } ApplicationDirectory dir = evidence.GetHostEvidence <ApplicationDirectory>(); Url url = evidence.GetHostEvidence <Url>(); if (dir != null && url != null) { // We need to add a wildcard at the end because IsSubsetOf keys off of it. String appDir = dir.Directory; if (appDir != null && appDir.Length > 1) { if (appDir[appDir.Length - 1] == '/') { appDir += "*"; } else { appDir += "/*"; } URLString appDirString = new URLString(appDir); if (url.GetURLString().IsSubsetOf(appDirString)) { usedEvidence = dir; return(true); } } } return(false); }
private PolicyStatement CalculateAssemblyPolicy(Evidence evidence) { PolicyStatement policyStatement = (PolicyStatement)null; Url hostEvidence1 = evidence.GetHostEvidence <Url>(); if (hostEvidence1 != null) { policyStatement = this.CalculatePolicy(hostEvidence1.GetURLString().Host, hostEvidence1.GetURLString().Scheme, hostEvidence1.GetURLString().Port); } if (policyStatement == null) { Site hostEvidence2 = evidence.GetHostEvidence <Site>(); if (hostEvidence2 != null) { policyStatement = this.CalculatePolicy(hostEvidence2.Name, (string)null, (string)null); } } if (policyStatement == null) { policyStatement = new PolicyStatement(new PermissionSet(false), PolicyStatementAttribute.Nothing); } return(policyStatement); }
/// <include file='doc\NetCodeGroup.uex' path='docs/doc[@for="NetCodeGroup.Resolve"]/*' /> public override PolicyStatement Resolve(Evidence evidence) { if (evidence == null) { throw new ArgumentNullException("evidence"); } if (this.MembershipCondition.Check(evidence)) { PolicyStatement thisPolicy = null; IEnumerator evidenceEnumerator = evidence.GetHostEnumerator(); Site site = null; while (evidenceEnumerator.MoveNext()) { Url url = evidenceEnumerator.Current as Url; if (url != null) { thisPolicy = CalculatePolicy(url.GetURLString().Host, url.GetURLString().Scheme); } else { if (site == null) { site = evidenceEnumerator.Current as Site; } } } if (thisPolicy == null && site != null) { thisPolicy = CalculatePolicy(site.Name, null); } if (thisPolicy == null) { thisPolicy = new PolicyStatement(new PermissionSet(false), PolicyStatementAttribute.Nothing); } IEnumerator enumerator = this.Children.GetEnumerator(); while (enumerator.MoveNext()) { PolicyStatement childPolicy = ((CodeGroup)enumerator.Current).Resolve(evidence); if (childPolicy != null) { if (((thisPolicy.Attributes & childPolicy.Attributes) & PolicyStatementAttribute.Exclusive) == PolicyStatementAttribute.Exclusive) { throw new PolicyException(Environment.GetResourceString("Policy_MultipleExclusive")); } thisPolicy.GetPermissionSetNoCopy().InplaceUnion(childPolicy.GetPermissionSetNoCopy()); thisPolicy.Attributes = thisPolicy.Attributes | childPolicy.Attributes; } } return(thisPolicy); } else { return(null); } }
private PolicyStatement CalculatePolicy( Url url ) { URLString urlString = url.GetURLString(); if (String.Compare( urlString.Scheme, "file", true, CultureInfo.InvariantCulture) != 0) return null; String directory = urlString.GetDirectoryName(); PermissionSet permSet = new PermissionSet( PermissionState.None ); permSet.SetPermission( new FileIOPermission( m_access, directory ) ); return new PolicyStatement( permSet, PolicyStatementAttribute.Nothing ); }