コード例 #1
0
 public IEnumerable <EvidenceBase> GetFactorySuppliedEvidence()
 {
     if (this.m_assemblyProvidedEvidence == null)
     {
         byte[] o = (byte[])null;
         PEFileEvidenceFactory.GetAssemblySuppliedEvidence(this.m_peFile, JitHelpers.GetObjectHandleOnStack <byte[]>(ref o));
         this.m_assemblyProvidedEvidence = new List <EvidenceBase>();
         if (o != null)
         {
             Evidence evidence = new Evidence();
             new SecurityPermission(SecurityPermissionFlag.SerializationFormatter).Assert();
             try
             {
                 using (MemoryStream memoryStream = new MemoryStream(o))
                     evidence = (Evidence) new BinaryFormatter().Deserialize((Stream)memoryStream);
             }
             catch
             {
             }
             CodeAccessPermission.RevertAssert();
             if (evidence != null)
             {
                 IEnumerator assemblyEnumerator = evidence.GetAssemblyEnumerator();
                 while (assemblyEnumerator.MoveNext())
                 {
                     if (assemblyEnumerator.Current != null)
                     {
                         this.m_assemblyProvidedEvidence.Add(assemblyEnumerator.Current as EvidenceBase ?? (EvidenceBase) new LegacyEvidenceWrapper(assemblyEnumerator.Current));
                     }
                 }
             }
         }
     }
     return((IEnumerable <EvidenceBase>) this.m_assemblyProvidedEvidence);
 }
コード例 #2
0
        /// <summary>
        ///     Create a factory which can generate evidence for the specified assembly
        /// </summary>
        private AssemblyEvidenceFactory(RuntimeAssembly targetAssembly, PEFileEvidenceFactory peFileFactory)
        {
            Contract.Assert(targetAssembly != null);
            Contract.Assert(peFileFactory != null);

            m_targetAssembly = targetAssembly;
            m_peFileFactory  = peFileFactory;
        }
コード例 #3
0
        /// <summary>
        ///     Create a factory which can generate evidence for the specified assembly
        /// </summary> 
        private AssemblyEvidenceFactory(RuntimeAssembly targetAssembly, PEFileEvidenceFactory peFileFactory)
        { 
            Contract.Assert(targetAssembly != null); 
            Contract.Assert(peFileFactory != null);
 
            m_targetAssembly = targetAssembly;
            m_peFileFactory = peFileFactory;
        }
 private static Evidence CreateSecurityIdentity(SafePEFileHandle peFile, Evidence hostProvidedEvidence)
 {
     PEFileEvidenceFactory target = new PEFileEvidenceFactory(peFile);
     Evidence evidence = new Evidence(target);
     if (hostProvidedEvidence != null)
     {
         evidence.MergeWithNoDuplicates(hostProvidedEvidence);
     }
     return evidence;
 }
コード例 #5
0
 private Publisher GeneratePublisherEvidence()
 {
     byte[] array = null;
     PEFileEvidenceFactory.GetPublisherCertificate(this.m_peFile, JitHelpers.GetObjectHandleOnStack <byte[]>(ref array));
     if (array == null)
     {
         return(null);
     }
     return(new Publisher(new X509Certificate(array)));
 }
コード例 #6
0
        private static Evidence CreateSecurityIdentity(SafePEFileHandle peFile, Evidence hostProvidedEvidence)
        {
            PEFileEvidenceFactory target = new PEFileEvidenceFactory(peFile);
            Evidence evidence            = new Evidence(target);

            if (hostProvidedEvidence != null)
            {
                evidence.MergeWithNoDuplicates(hostProvidedEvidence);
            }
            return(evidence);
        }
コード例 #7
0
        private static Evidence CreateSecurityIdentity(SafePEFileHandle peFile,
                                                       Evidence hostProvidedEvidence)
        {
            PEFileEvidenceFactory evidenceFactory = new PEFileEvidenceFactory(peFile);
            Evidence evidence = new Evidence(evidenceFactory);

            // If the host (caller of Assembly.Load) provided evidence, merge it with the evidence we've just
            // created. The host evidence takes priority.
            if (hostProvidedEvidence != null)
            {
                evidence.MergeWithNoDuplicates(hostProvidedEvidence);
            }

            return(evidence);
        }
コード例 #8
0
 private void GenerateLocationEvidence()
 {
     if (!this.m_generatedLocationEvidence)
     {
         SecurityZone securityZone = SecurityZone.NoZone;
         string       text         = null;
         PEFileEvidenceFactory.GetLocationEvidence(this.m_peFile, out securityZone, JitHelpers.GetStringHandleOnStack(ref text));
         if (securityZone != SecurityZone.NoZone)
         {
             this.m_zoneEvidence = new Zone(securityZone);
         }
         if (!string.IsNullOrEmpty(text))
         {
             this.m_urlEvidence = new Url(text, true);
             if (!text.StartsWith("file:", StringComparison.OrdinalIgnoreCase))
             {
                 this.m_siteEvidence = Site.CreateFromUrl(text);
             }
         }
         this.m_generatedLocationEvidence = true;
     }
 }
コード例 #9
0
        private void GenerateLocationEvidence()
        {
            if (this.m_generatedLocationEvidence)
            {
                return;
            }
            SecurityZone zone = SecurityZone.NoZone;
            string       s    = (string)null;

            PEFileEvidenceFactory.GetLocationEvidence(this.m_peFile, out zone, JitHelpers.GetStringHandleOnStack(ref s));
            if (zone != SecurityZone.NoZone)
            {
                this.m_zoneEvidence = new Zone(zone);
            }
            if (!string.IsNullOrEmpty(s))
            {
                this.m_urlEvidence = new Url(s, true);
                if (!s.StartsWith("file:", StringComparison.OrdinalIgnoreCase))
                {
                    this.m_siteEvidence = Site.CreateFromUrl(s);
                }
            }
            this.m_generatedLocationEvidence = true;
        }
コード例 #10
0
 private AssemblyEvidenceFactory(RuntimeAssembly targetAssembly, PEFileEvidenceFactory peFileFactory)
 {
     this.m_targetAssembly = targetAssembly;
     this.m_peFileFactory  = peFileFactory;
 }
コード例 #11
0
 internal void FireEvidenceGeneratedEvent(EvidenceTypeGenerated type)
 {
     PEFileEvidenceFactory.FireEvidenceGeneratedEvent(this.m_peFile, type);
 }
コード例 #12
0
        private static Evidence CreateSecurityIdentity(SafePEFileHandle peFile,
                                                       Evidence hostProvidedEvidence)
        {

            PEFileEvidenceFactory evidenceFactory = new PEFileEvidenceFactory(peFile);
            Evidence evidence = new Evidence(evidenceFactory);

            // If the host (caller of Assembly.Load) provided evidence, merge it with the evidence we've just
            // created. The host evidence takes priority.
            if (hostProvidedEvidence != null)
            {
                evidence.MergeWithNoDuplicates(hostProvidedEvidence);
            }

            return evidence;
        }
 private AssemblyEvidenceFactory(RuntimeAssembly targetAssembly, PEFileEvidenceFactory peFileFactory)
 {
     this.m_targetAssembly = targetAssembly;
     this.m_peFileFactory = peFileFactory;
 }