CreateFromUrl() public static method

public static CreateFromUrl ( string url ) : Site
url string
return Site
Esempio n. 1
0
        private void GenerateLocationEvidence()
        {
            if (!m_generatedLocationEvidence)
            {
                SecurityZone securityZone = SecurityZone.NoZone;
                string       url          = null;
                GetLocationEvidence(m_peFile, out securityZone, JitHelpers.GetStringHandleOnStack(ref url));

                if (securityZone != SecurityZone.NoZone)
                {
                    m_zoneEvidence = new Zone(securityZone);
                }

                if (!String.IsNullOrEmpty(url))
                {
                    m_urlEvidence = new Url(url, true);

                    // We only create site evidence if the URL does not with file:
                    if (!url.StartsWith("file:", StringComparison.OrdinalIgnoreCase))
                    {
                        m_siteEvidence = Site.CreateFromUrl(url);
                    }
                }

                m_generatedLocationEvidence = true;
            }
        }
Esempio n. 2
0
        static internal Evidence GetDefaultHostEvidence(Assembly a)
        {
            Evidence e     = new Evidence();
            string   aname = a.EscapedCodeBase;

            // by default all assembly have the Zone, Url and Hash evidences
            e.AddHost(Zone.CreateFromUrl(aname));
            e.AddHost(new Url(aname));
            e.AddHost(new Hash(a));

            // non local files (e.g. http://) also get a Site evidence
            if (String.Compare("FILE://", 0, aname, 0, 7, true, CultureInfo.InvariantCulture) != 0)
            {
                e.AddHost(Site.CreateFromUrl(aname));
            }

            // strongnamed assemblies gets a StrongName evidence
            AssemblyName an = a.GetName();

            byte[] pk = an.GetPublicKey();
            if ((pk != null) && (pk.Length > 0))
            {
                StrongNamePublicKeyBlob blob = new StrongNamePublicKeyBlob(pk);
                e.AddHost(new StrongName(blob, an.Name, an.Version));
            }

            // Authenticode(r) signed assemblies get a Publisher evidence
            if (IsAuthenticodePresent(a))
            {
                try {
                    X509Certificate x509 = X509Certificate.CreateFromSignedFile(a.Location);
                    e.AddHost(new Publisher(x509));
                }
                catch (CryptographicException) {
                }
            }

            // assemblies loaded from the GAC also get a Gac evidence (new in Fx 2.0)
            if (a.GlobalAssemblyCache)
            {
                e.AddHost(new GacInstalled());
            }

            // the current HostSecurityManager may add/remove some evidence
            AppDomainManager dommgr = AppDomain.CurrentDomain.DomainManager;

            if (dommgr != null)
            {
                if ((dommgr.HostSecurityManager.Flags & HostSecurityManagerOptions.HostAssemblyEvidence) ==
                    HostSecurityManagerOptions.HostAssemblyEvidence)
                {
                    e = dommgr.HostSecurityManager.ProvideAssemblyEvidence(a, e);
                }
            }

            return(e);
        }
 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;
     }
 }
        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;
        }