bool IReportMatchMembershipCondition.Check(Evidence evidence, out object usedEvidence)
        {
            usedEvidence = null;

            if (evidence == null)
            {
                return(false);
            }

            StrongName name = evidence.GetDelayEvaluatedHostEvidence <StrongName>();

            if (name != null)
            {
                bool publicKeyMatch = PublicKey != null && PublicKey.Equals(name.PublicKey);
                bool nameMatch      = Name == null || (name.Name != null && StrongName.CompareNames(name.Name, Name));
                bool versionMatch   = (object)Version == null || ((object)name.Version != null && name.Version.CompareTo(Version) == 0);

                if (publicKeyMatch && nameMatch && versionMatch)
                {
                    // Note that we explicitly do not want to mark the strong name evidence as used at
                    // this point, since we could be a child code group where our parent provides more
                    // trust than we do.  For instance, if we're in a setup like this:
                    //
                    //   AllCode -> FullTrust
                    //     StrongName -> FullTrust
                    //
                    // the StrongName code group didn't add anything to the final grant set and therefore
                    // does not need to be evaluated.
                    usedEvidence = name;
                    return(true);
                }
            }

            return(false);
        }
 bool IReportMatchMembershipCondition.Check(Evidence evidence, out object usedEvidence)
 {
     usedEvidence = null;
     if (evidence != null)
     {
         StrongName delayEvaluatedHostEvidence = evidence.GetDelayEvaluatedHostEvidence <StrongName>();
         if (delayEvaluatedHostEvidence != null)
         {
             bool flag  = (this.PublicKey != null) && this.PublicKey.Equals(delayEvaluatedHostEvidence.PublicKey);
             bool flag2 = (this.Name == null) || ((delayEvaluatedHostEvidence.Name != null) && StrongName.CompareNames(delayEvaluatedHostEvidence.Name, this.Name));
             bool flag3 = (this.Version == null) || ((delayEvaluatedHostEvidence.Version != null) && (delayEvaluatedHostEvidence.Version.CompareTo(this.Version) == 0));
             if ((flag && flag2) && flag3)
             {
                 usedEvidence = delayEvaluatedHostEvidence;
                 return(true);
             }
         }
     }
     return(false);
 }
        bool IReportMatchMembershipCondition.Check(Evidence evidence, out object usedEvidence)
        {
            usedEvidence = (object)null;
            if (evidence == null)
            {
                return(false);
            }
            StrongName evaluatedHostEvidence = evidence.GetDelayEvaluatedHostEvidence <StrongName>();

            if (evaluatedHostEvidence != null)
            {
                int  num1  = this.PublicKey == null ? 0 : (this.PublicKey.Equals(evaluatedHostEvidence.PublicKey) ? 1 : 0);
                bool flag1 = this.Name == null || evaluatedHostEvidence.Name != null && StrongName.CompareNames(evaluatedHostEvidence.Name, this.Name);
                bool flag2 = this.Version == null || evaluatedHostEvidence.Version != null && evaluatedHostEvidence.Version.CompareTo(this.Version) == 0;
                int  num2  = flag1 ? 1 : 0;
                if ((num1 & num2 & (flag2 ? 1 : 0)) != 0)
                {
                    usedEvidence = (object)evaluatedHostEvidence;
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 4
0
        internal PermissionSet GetHomogenousGrantSet(Evidence evidence)
        {
            Contract.Assert(evidence != null);
            Contract.Assert(IsHomogenous);
            Contract.Assert(evidence.GetHostEvidence<GacInstalled>() == null);

            if (_IsFastFullTrustDomain)
            {
                return new PermissionSet(PermissionState.Unrestricted);
            }

            // If the ApplicationTrust's full trust list calls out the assembly, then it is fully trusted
            if (evidence.GetDelayEvaluatedHostEvidence<StrongName>() != null)
            {
                foreach (StrongName fullTrustAssembly in ApplicationTrust.FullTrustAssemblies)
                {
                    StrongNameMembershipCondition sn = new StrongNameMembershipCondition(fullTrustAssembly.PublicKey,
                                                                                         fullTrustAssembly.Name,
                                                                                         fullTrustAssembly.Version);

                    object usedEvidence = null;
                    if ((sn as IReportMatchMembershipCondition).Check(evidence, out usedEvidence))
                    {
                        IDelayEvaluatedEvidence delayEvidence = usedEvidence as IDelayEvaluatedEvidence;
                        if (usedEvidence != null)
                        {
                            delayEvidence.MarkUsed();
                        }

                        return new PermissionSet(PermissionState.Unrestricted);
                    }
                }
            }

            // Otherwise, the grant set is just the default grant set
            return ApplicationTrust.DefaultGrantSet.PermissionSet.Copy();
        }
        bool IReportMatchMembershipCondition.Check(Evidence evidence, out object usedEvidence)
        {
            usedEvidence = null;

            if (evidence == null)
                return false;

            StrongName name = evidence.GetDelayEvaluatedHostEvidence<StrongName>();                
            if (name != null)
            {
                bool publicKeyMatch = PublicKey != null && PublicKey.Equals(name.PublicKey);
                bool nameMatch = Name == null || (name.Name != null && StrongName.CompareNames(name.Name, Name));
                bool versionMatch = (object)Version == null || ((object)name.Version != null && name.Version.CompareTo(Version) == 0);

                if (publicKeyMatch && nameMatch && versionMatch)
                {
                    // Note that we explicitly do not want to mark the strong name evidence as used at
                    // this point, since we could be a child code group where our parent provides more
                    // trust than we do.  For instance, if we're in a setup like this:
                    //
                    //   AllCode -> FullTrust
                    //     StrongName -> FullTrust
                    //
                    // the StrongName code group didn't add anything to the final grant set and therefore
                    // does not need to be evaluated.
                    usedEvidence = name;
                    return true;
                }
            }

            return false;
        }
 bool IReportMatchMembershipCondition.Check(Evidence evidence, out object usedEvidence)
 {
     usedEvidence = null;
     if (evidence != null)
     {
         StrongName delayEvaluatedHostEvidence = evidence.GetDelayEvaluatedHostEvidence<StrongName>();
         if (delayEvaluatedHostEvidence != null)
         {
             bool flag = (this.PublicKey != null) && this.PublicKey.Equals(delayEvaluatedHostEvidence.PublicKey);
             bool flag2 = (this.Name == null) || ((delayEvaluatedHostEvidence.Name != null) && StrongName.CompareNames(delayEvaluatedHostEvidence.Name, this.Name));
             bool flag3 = (this.Version == null) || ((delayEvaluatedHostEvidence.Version != null) && (delayEvaluatedHostEvidence.Version.CompareTo(this.Version) == 0));
             if ((flag && flag2) && flag3)
             {
                 usedEvidence = delayEvaluatedHostEvidence;
                 return true;
             }
         }
     }
     return false;
 }
		internal PermissionSet GetHomogenousGrantSet(Evidence evidence)
		{
			if (evidence.GetDelayEvaluatedHostEvidence<StrongName>() != null)
			{
				foreach (StrongName current in this._applicationTrust.FullTrustAssemblies)
				{
					StrongNameMembershipCondition strongNameMembershipCondition = new StrongNameMembershipCondition(current.PublicKey, current.Name, current.Version);
					object obj = null;
					if (((IReportMatchMembershipCondition)strongNameMembershipCondition).Check(evidence, out obj))
					{
						IDelayEvaluatedEvidence delayEvaluatedEvidence = obj as IDelayEvaluatedEvidence;
						if (obj != null)
						{
							delayEvaluatedEvidence.MarkUsed();
						}
						return new PermissionSet(PermissionState.Unrestricted);
					}
				}
			}
			return this._applicationTrust.DefaultGrantSet.PermissionSet.Copy();
		}