Exemplo n.º 1
0
 /// <include file='doc\URLIdentityPermission.uex' path='docs/doc[@for="UrlIdentityPermission.UrlIdentityPermission1"]/*' />
 public UrlIdentityPermission( String site )
 {
     if (site == null)
         throw new ArgumentNullException( "site" );
         
     m_url = new URLString( site );
 }
Exemplo n.º 2
0
        public override bool IsSubsetOf(SiteString site)
        {
            if (site == null)
            {
                return(false);
            }
            URLString urlString1 = site as URLString;

            if (urlString1 == null)
            {
                return(false);
            }
            this.DoDeferredParse();
            urlString1.DoDeferredParse();
            URLString urlString2 = this.SpecialNormalizeUrl();
            URLString urlString3 = urlString1.SpecialNormalizeUrl();

            if (string.Compare(urlString2.m_protocol, urlString3.m_protocol, StringComparison.OrdinalIgnoreCase) != 0 || !urlString2.m_directory.IsSubsetOf(urlString3.m_directory))
            {
                return(false);
            }
            if (urlString2.m_localSite != null)
            {
                return(urlString2.m_localSite.IsSubsetOf(urlString3.m_localSite));
            }
            if (urlString2.m_port != urlString3.m_port || urlString3.m_siteString == null)
            {
                return(false);
            }
            return(urlString2.m_siteString.IsSubsetOf(urlString3.m_siteString));
        }
 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;
 }
Exemplo n.º 4
0
        internal URLString SpecialNormalizeUrl()
        {
            this.DoDeferredParse();
            if (string.Compare(this.m_protocol, "file", StringComparison.OrdinalIgnoreCase) != 0)
            {
                return(this);
            }
            string @string = this.m_localSite.ToString();

            if (@string.Length != 2 || (int)@string[1] != 124 && (int)@string[1] != 58)
            {
                return(this);
            }
            string s = (string)null;

            URLString.GetDeviceName(@string, JitHelpers.GetStringHandleOnStack(ref s));
            if (s == null)
            {
                return(this);
            }
            if (s.IndexOf("://", StringComparison.Ordinal) != -1)
            {
                URLString urlString = new URLString(s + "/" + this.m_directory.ToString());
                urlString.DoDeferredParse();
                return(urlString);
            }
            URLString urlString1 = new URLString("file://" + s + "/" + this.m_directory.ToString());

            urlString1.DoDeferredParse();
            return(urlString1);
        }
Exemplo n.º 5
0
        public static bool CompareUrls(URLString url1, URLString url2)
        {
            if (url1 == null && url2 == null)
            {
                return(true);
            }
            if (url1 == null || url2 == null)
            {
                return(false);
            }
            url1.DoDeferredParse();
            url2.DoDeferredParse();
            URLString urlString1 = url1.SpecialNormalizeUrl();
            URLString urlString2 = url2.SpecialNormalizeUrl();

            if (string.Compare(urlString1.m_protocol, urlString2.m_protocol, StringComparison.OrdinalIgnoreCase) != 0)
            {
                return(false);
            }
            if (string.Compare(urlString1.m_protocol, "file", StringComparison.OrdinalIgnoreCase) == 0)
            {
                if (!urlString1.m_localSite.IsSubsetOf(urlString2.m_localSite) || !urlString2.m_localSite.IsSubsetOf(urlString1.m_localSite))
                {
                    return(false);
                }
            }
            else if (string.Compare(urlString1.m_userpass, urlString2.m_userpass, StringComparison.Ordinal) != 0 || !urlString1.m_siteString.IsSubsetOf(urlString2.m_siteString) || (!urlString2.m_siteString.IsSubsetOf(urlString1.m_siteString) || url1.m_port != url2.m_port))
            {
                return(false);
            }
            return(urlString1.m_directory.IsSubsetOf(urlString2.m_directory) && urlString2.m_directory.IsSubsetOf(urlString1.m_directory));
        }
        internal URLString SpecialNormalizeUrl()
        {
            this.DoDeferredParse();
            if (string.Compare(this.m_protocol, "file", StringComparison.OrdinalIgnoreCase) != 0)
            {
                return(this);
            }
            string driveLetter = this.m_localSite.ToString();

            if ((driveLetter.Length != 2) || ((driveLetter[1] != '|') && (driveLetter[1] != ':')))
            {
                return(this);
            }
            string s = null;

            GetDeviceName(driveLetter, JitHelpers.GetStringHandleOnStack(ref s));
            if (s == null)
            {
                return(this);
            }
            if (s.IndexOf("://", StringComparison.Ordinal) != -1)
            {
                URLString str3 = new URLString(s + "/" + this.m_directory.ToString());
                str3.DoDeferredParse();
                return(str3);
            }
            URLString str4 = new URLString("file://" + s + "/" + this.m_directory.ToString());

            str4.DoDeferredParse();
            return(str4);
        }
Exemplo n.º 7
0
 /// <include file='doc\URL.uex' path='docs/doc[@for="Url.Url"]/*' />
 public Url( String name )
 {
     if (name == null)
         throw new ArgumentNullException( "name" );
 
     m_url = new URLString( name );
 }
        public override bool IsSubsetOf(SiteString site)
        {
            if (site == null)
            {
                return(false);
            }
            URLString str = site as URLString;

            if (str == null)
            {
                return(false);
            }
            this.DoDeferredParse();
            str.DoDeferredParse();
            URLString str2 = this.SpecialNormalizeUrl();
            URLString str3 = str.SpecialNormalizeUrl();

            if ((string.Compare(str2.m_protocol, str3.m_protocol, StringComparison.OrdinalIgnoreCase) != 0) || !str2.m_directory.IsSubsetOf(str3.m_directory))
            {
                return(false);
            }
            if (str2.m_localSite != null)
            {
                return(str2.m_localSite.IsSubsetOf(str3.m_localSite));
            }
            if (str2.m_port != str3.m_port)
            {
                return(false);
            }
            return((str3.m_siteString != null) && str2.m_siteString.IsSubsetOf(str3.m_siteString));
        }
Exemplo n.º 9
0
 /// <include file='doc\ApplicationDirectory.uex' path='docs/doc[@for="ApplicationDirectory.ApplicationDirectory"]/*' />
 public ApplicationDirectory( String name )
 {
     if (name == null)
         throw new ArgumentNullException( "name" );
 
     m_appDirectory = new URLString( name );
 }
        internal URLString SpecialNormalizeUrl()
        {
            this.DoDeferredParse();
            if (string.Compare(this.m_protocol, "file", StringComparison.OrdinalIgnoreCase) != 0)
            {
                return(this);
            }
            string text = this.m_localSite.ToString();

            if (text.Length != 2 || (text[1] != '|' && text[1] != ':'))
            {
                return(this);
            }
            string text2 = null;

            URLString.GetDeviceName(text, JitHelpers.GetStringHandleOnStack(ref text2));
            if (text2 == null)
            {
                return(this);
            }
            if (text2.IndexOf("://", StringComparison.Ordinal) != -1)
            {
                URLString urlstring = new URLString(text2 + "/" + this.m_directory.ToString());
                urlstring.DoDeferredParse();
                return(urlstring);
            }
            URLString urlstring2 = new URLString("file://" + text2 + "/" + this.m_directory.ToString());

            urlstring2.DoDeferredParse();
            return(urlstring2);
        }
Exemplo n.º 11
0
 internal Url( String name, bool parsed )
 {
     if (name == null)
         throw new ArgumentNullException( "name" );
 
     m_url = new URLString( name, parsed );
 }
Exemplo n.º 12
0
        internal Url( String name, bool parsed )
        {
            if (name == null)
                throw new ArgumentNullException( nameof(name) );
            Contract.EndContractBlock();

            m_url = new URLString( name, parsed );
        }
 private void OnSerialized(StreamingContext ctx)
 {
     if ((ctx.State & ~(StreamingContextStates.Clone|StreamingContextStates.CrossAppDomain)) != 0)
     {
         m_serializedPermission = null;
         m_url = null;
     }
 }
Exemplo n.º 14
0
        public Url( String name ) 
        {
            if (name == null)
                throw new ArgumentNullException( "name" );
            Contract.EndContractBlock(); 

            m_url = new URLString( name ); 
        } 
        public UrlMembershipCondition( String url )
        {
            if (url == null)
                throw new ArgumentNullException( "url" );

            // Parse the Url to check that it's valid.
            m_url = new URLString(url, false /* not parsed */, true /* parse eagerly */);
        }
 private static SiteString ParseSiteFromUrl(string name)
 {
     URLString str = new URLString(name);
     if (string.Compare(str.Scheme, "file", StringComparison.OrdinalIgnoreCase) == 0)
     {
         throw new ArgumentException(Environment.GetResourceString("Argument_InvalidSite"));
     }
     return new SiteString(new URLString(name).Host);
 }
        private void OnSerializing(StreamingContext ctx)
        {

            if ((ctx.State & ~(StreamingContextStates.Clone|StreamingContextStates.CrossAppDomain)) != 0)
            {
                m_serializedPermission = ToXml().ToString(); //for the v2 and beyond case
                if (m_urls != null && m_urls.Length == 1) // for the v1.x case
                    m_url = m_urls[0];
                
            }
        }   
        public UrlMembershipCondition( String url )
        {
            if (url == null)
                throw new ArgumentNullException( "url" );
            Contract.EndContractBlock();

            // Parse the Url to check that it's valid.
            m_url = new URLString(url, false /* not parsed */, true /* parse eagerly */);

            if (m_url.IsRelativeFileUrl)
                throw new ArgumentException(Environment.GetResourceString("Argument_RelativeUrlMembershipCondition"), "url");
        }
 // Token: 0x06002B66 RID: 11110 RVA: 0x000A1CFA File Offset: 0x0009FEFA
 private string PreProcessURL(string url, bool isFileURL)
 {
     if (isFileURL)
     {
         url = URLString.PreProcessForExtendedPathRemoval(url, true, ref this.m_isUncShare);
     }
     else
     {
         url = url.Replace('\\', '/');
     }
     return(url);
 }
        // Token: 0x06002B64 RID: 11108 RVA: 0x000A1B88 File Offset: 0x0009FD88
        private static string PreProcessForExtendedPathRemoval(bool checkPathLength, string url, bool isFileUrl, ref bool isUncShare)
        {
            StringBuilder stringBuilder = new StringBuilder(url);
            int           num           = 0;
            int           num2          = 0;

            if (url.Length - num >= 4 && (string.Compare(url, num, "//?/", 0, 4, StringComparison.OrdinalIgnoreCase) == 0 || string.Compare(url, num, "//./", 0, 4, StringComparison.OrdinalIgnoreCase) == 0))
            {
                stringBuilder.Remove(num2, 4);
                num += 4;
            }
            else
            {
                if (isFileUrl)
                {
                    while (url[num] == '/')
                    {
                        num++;
                        num2++;
                    }
                }
                if (url.Length - num >= 4 && (string.Compare(url, num, "\\\\?\\", 0, 4, StringComparison.OrdinalIgnoreCase) == 0 || string.Compare(url, num, "\\\\?/", 0, 4, StringComparison.OrdinalIgnoreCase) == 0 || string.Compare(url, num, "\\\\.\\", 0, 4, StringComparison.OrdinalIgnoreCase) == 0 || string.Compare(url, num, "\\\\./", 0, 4, StringComparison.OrdinalIgnoreCase) == 0))
                {
                    stringBuilder.Remove(num2, 4);
                    num += 4;
                }
            }
            if (isFileUrl)
            {
                int  num3 = 0;
                bool flag = false;
                while (num3 < stringBuilder.Length && (stringBuilder[num3] == '/' || stringBuilder[num3] == '\\'))
                {
                    if (!flag && stringBuilder[num3] == '\\')
                    {
                        flag = true;
                        if (num3 + 1 < stringBuilder.Length && stringBuilder[num3 + 1] == '\\')
                        {
                            isUncShare = true;
                        }
                    }
                    num3++;
                }
                stringBuilder.Remove(0, num3);
                stringBuilder.Replace('\\', '/');
            }
            if (checkPathLength)
            {
                URLString.CheckPathTooLong(stringBuilder);
            }
            return(stringBuilder.ToString());
        }
Exemplo n.º 21
0
        public static bool CompareUrls(URLString url1, URLString url2)
        {
            if (url1 == null && url2 == null)
            {
                return(true);
            }

            if (url1 == null || url2 == null)
            {
                return(false);
            }

            URLString normalUrl1 = url1.SpecialNormalizeUrl();
            URLString normalUrl2 = url2.SpecialNormalizeUrl();

            // Compare protocol (case insensitive)

            if (String.Compare(normalUrl1.m_protocol, normalUrl2.m_protocol, true, CultureInfo.InvariantCulture) != 0)
            {
                return(false);
            }

            // Do special processing for file urls

            if (String.Compare(normalUrl1.m_protocol, "file", true, CultureInfo.InvariantCulture) == 0)
            {
                return(normalUrl1.m_localSite.IsSubsetOf(normalUrl2.m_localSite) &&
                       normalUrl2.m_localSite.IsSubsetOf(normalUrl1.m_localSite));
            }
            else
            {
                if (!normalUrl1.m_siteString.IsSubsetOf(normalUrl2.m_siteString) ||
                    !normalUrl2.m_siteString.IsSubsetOf(normalUrl1.m_siteString))
                {
                    return(false);
                }

                if (url1.m_port != url2.m_port)
                {
                    return(false);
                }
            }

            if (!normalUrl1.m_directory.IsSubsetOf(normalUrl2.m_directory) ||
                !normalUrl2.m_directory.IsSubsetOf(normalUrl1.m_directory))
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 22
0
        internal URLString SpecialNormalizeUrl()
        {
            // Under WinXP, file protocol urls can be mapped to
            // drives that aren't actually file protocol underneath
            // due to drive mounting.  This code attempts to figure
            // out what a drive is mounted to and create the
            // url is maps to.

            DoDeferredParse();
            if (String.Compare(m_protocol, "file", StringComparison.OrdinalIgnoreCase) != 0)
            {
                return(this);
            }
            else
            {
                String localSite = m_localSite.ToString();

                if (localSite.Length == 2 &&
                    (localSite[1] == '|' ||
                     localSite[1] == ':'))
                {
                    String deviceName = null;
                    GetDeviceName(localSite, JitHelpers.GetStringHandleOnStack(ref deviceName));

                    if (deviceName != null)
                    {
                        if (deviceName.IndexOf("://", StringComparison.Ordinal) != -1)
                        {
                            URLString u = new URLString(deviceName + "/" + this.m_directory.ToString());
                            u.DoDeferredParse(); // Presumably the caller of SpecialNormalizeUrl wants a fully parsed URL
                            return(u);
                        }
                        else
                        {
                            URLString u = new URLString("file://" + deviceName + "/" + this.m_directory.ToString());
                            u.DoDeferredParse();// Presumably the caller of SpecialNormalizeUrl wants a fully parsed URL
                            return(u);
                        }
                    }
                    else
                    {
                        return(this);
                    }
                }
                else
                {
                    return(this);
                }
            }
        }
Exemplo n.º 23
0
  //------------------------------------------------------
  //
  // PUBLIC CONSTRUCTORS
  //
  //------------------------------------------------------
  
 
  /// <include file='doc\URLIdentityPermission.uex' path='docs/doc[@for="UrlIdentityPermission.UrlIdentityPermission"]/*' />
  public UrlIdentityPermission(PermissionState state)
  {
      if (state == PermissionState.Unrestricted)
      {
          throw new ArgumentException(Environment.GetResourceString("Argument_UnrestrictedIdentityPermission"));
      }
      else if (state == PermissionState.None)
      {
          m_url = null;
      }
      else
      {
          throw new ArgumentException(Environment.GetResourceString("Argument_InvalidPermissionState"));
      }
  }
Exemplo n.º 24
0
        public override bool IsSubsetOf(SiteString site)
        {
            if (site == null)
            {
                return(false);
            }

            URLString url = site as URLString;

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

            DoDeferredParse();
            url.DoDeferredParse();

            URLString normalUrl1 = this.SpecialNormalizeUrl();
            URLString normalUrl2 = url.SpecialNormalizeUrl();

            if (String.Compare(normalUrl1.m_protocol, normalUrl2.m_protocol, StringComparison.OrdinalIgnoreCase) == 0 &&
                normalUrl1.m_directory.IsSubsetOf(normalUrl2.m_directory))
            {
#if !PLATFORM_UNIX
                if (normalUrl1.m_localSite != null)
                {
                    // We do a little extra processing in here for local files since we allow
                    // both <drive_letter>: and <drive_letter>| forms of urls.

                    return(normalUrl1.m_localSite.IsSubsetOf(normalUrl2.m_localSite));
                }
                else
#endif // !PLATFORM_UNIX
                {
                    if (normalUrl1.m_port != normalUrl2.m_port)
                    {
                        return(false);
                    }

                    return(normalUrl2.m_siteString != null && normalUrl1.m_siteString.IsSubsetOf(normalUrl2.m_siteString));
                }
            }
            else
            {
                return(false);
            }
        }
        private void OnDeserialized(StreamingContext ctx)
        {
            // v2.0 and beyond XML case
            if (m_serializedPermission != null)
            {
                FromXml(SecurityElement.FromString(m_serializedPermission));
                m_serializedPermission = null;
            }
            else if (m_url != null) //v1.x case where we read the m_site value
            {
                m_unrestricted = false;
                m_urls = new URLString[1];
                m_urls[0] = m_url;
                m_url = null;
            }

        }
 public static bool CompareUrls(URLString url1, URLString url2)
 {
     if ((url1 == null) && (url2 == null))
     {
         return true;
     }
     if ((url1 == null) || (url2 == null))
     {
         return false;
     }
     url1.DoDeferredParse();
     url2.DoDeferredParse();
     URLString str = url1.SpecialNormalizeUrl();
     URLString str2 = url2.SpecialNormalizeUrl();
     if (string.Compare(str.m_protocol, str2.m_protocol, StringComparison.OrdinalIgnoreCase) != 0)
     {
         return false;
     }
     if (string.Compare(str.m_protocol, "file", StringComparison.OrdinalIgnoreCase) == 0)
     {
         if (!str.m_localSite.IsSubsetOf(str2.m_localSite) || !str2.m_localSite.IsSubsetOf(str.m_localSite))
         {
             return false;
         }
     }
     else
     {
         if (string.Compare(str.m_userpass, str2.m_userpass, StringComparison.Ordinal) != 0)
         {
             return false;
         }
         if (!str.m_siteString.IsSubsetOf(str2.m_siteString) || !str2.m_siteString.IsSubsetOf(str.m_siteString))
         {
             return false;
         }
         if (url1.m_port != url2.m_port)
         {
             return false;
         }
     }
     return (str.m_directory.IsSubsetOf(str2.m_directory) && str2.m_directory.IsSubsetOf(str.m_directory));
 }
Exemplo n.º 27
0
        public override bool IsSubsetOf(SiteString site)
        {
            if (site == null)
            {
                return(false);
            }

            URLString url = site as URLString;

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

            URLString normalUrl1 = this.SpecialNormalizeUrl();
            URLString normalUrl2 = url.SpecialNormalizeUrl();

            if (String.Compare(normalUrl1.m_protocol, normalUrl2.m_protocol, true, CultureInfo.InvariantCulture) == 0 &&
                normalUrl1.m_directory.IsSubsetOf(normalUrl2.m_directory))
            {
                if (normalUrl1.m_localSite != null)
                {
                    // We do a little extra processing in here for local files since we allow
                    // both <drive_letter>: and <drive_letter>| forms of urls.

                    return(normalUrl1.m_localSite.IsSubsetOf(normalUrl2.m_localSite));
                }
                else
                {
                    if (normalUrl1.m_port != normalUrl2.m_port)
                    {
                        return(false);
                    }

                    return(normalUrl2.m_siteString != null && normalUrl1.m_siteString.IsSubsetOf(normalUrl2.m_siteString));
                }
            }
            else
            {
                return(false);
            }
        }
 // Token: 0x06002B63 RID: 11107 RVA: 0x000A1B7D File Offset: 0x0009FD7D
 private static string PreProcessForExtendedPathRemoval(string url, bool isFileUrl, ref bool isUncShare)
 {
     return(URLString.PreProcessForExtendedPathRemoval(true, url, isFileUrl, ref isUncShare));
 }
Exemplo n.º 29
0
        internal static string PreProcessForExtendedPathRemoval(string url, bool isFileUrl)
        {
            bool isUncShare = false;

            return(URLString.PreProcessForExtendedPathRemoval(url, isFileUrl, ref isUncShare));
        }
Exemplo n.º 30
0
        public static bool CompareUrls( URLString url1, URLString url2 )
        { 
            if (url1 == null && url2 == null) 
                return true;
 
            if (url1 == null || url2 == null)
                return false;

            url1.DoDeferredParse(); 
            url2.DoDeferredParse();
 
            URLString normalUrl1 = url1.SpecialNormalizeUrl(); 
            URLString normalUrl2 = url2.SpecialNormalizeUrl();
 
            // Compare protocol (case insensitive)

            if (String.Compare( normalUrl1.m_protocol, normalUrl2.m_protocol, StringComparison.OrdinalIgnoreCase) != 0)
                return false; 

            // Do special processing for file urls 
 
            if (String.Compare( normalUrl1.m_protocol, "file", StringComparison.OrdinalIgnoreCase) == 0)
            { 
#if !PLATFORM_UNIX
                if (!normalUrl1.m_localSite.IsSubsetOf( normalUrl2.m_localSite ) ||
                    !normalUrl2.m_localSite.IsSubsetOf( normalUrl1.m_localSite ))
                     return false; 
#else
                return url1.IsSubsetOf( url2 ) && 
                       url2.IsSubsetOf( url1 ); 
#endif // !PLATFORM_UNIX
            } 
            else
            {
                if (String.Compare( normalUrl1.m_userpass, normalUrl2.m_userpass, StringComparison.Ordinal) != 0)
                    return false; 

                if (!normalUrl1.m_siteString.IsSubsetOf( normalUrl2.m_siteString ) || 
                    !normalUrl2.m_siteString.IsSubsetOf( normalUrl1.m_siteString )) 
                    return false;
 
                if (url1.m_port != url2.m_port)
                    return false;
            }
 
            if (!normalUrl1.m_directory.IsSubsetOf( normalUrl2.m_directory ) ||
                !normalUrl2.m_directory.IsSubsetOf( normalUrl1.m_directory )) 
                return false; 

            return true; 
        }
Exemplo n.º 31
0
        internal URLString SpecialNormalizeUrl() 
        { 
            // Under WinXP, file protocol urls can be mapped to
            // drives that aren't actually file protocol underneath 
            // due to drive mounting.  This code attempts to figure
            // out what a drive is mounted to and create the
            // url is maps to.
 
            DoDeferredParse();
            if (String.Compare( m_protocol, "file", StringComparison.OrdinalIgnoreCase) != 0) 
            { 
                return this;
            } 
            else
            {
                String localSite = m_localSite.ToString();
 
                if (localSite.Length == 2 &&
                    (localSite[1] == '|' || 
                     localSite[1] == ':')) 
                {
                    String deviceName = null; 
                    GetDeviceName(localSite, JitHelpers.GetStringHandleOnStack(ref deviceName));

                    if (deviceName != null)
                    { 
                        if (deviceName.IndexOf( "://", StringComparison.Ordinal ) != -1)
                        { 
                            URLString u = new URLString( deviceName + "/" + this.m_directory.ToString() ); 
                            u.DoDeferredParse(); // Presumably the caller of SpecialNormalizeUrl wants a fully parsed URL
                            return u; 
                        }
                        else
                        {
                            URLString u = new URLString( "file://" + deviceName + "/" + this.m_directory.ToString() ); 
                            u.DoDeferredParse();// Presumably the caller of SpecialNormalizeUrl wants a fully parsed URL
                            return u; 
                        } 
                    }
                    else 
                        return this;
                }
                else
                { 
                    return this;
                } 
            } 
        }
 internal UrlIdentityPermission(URLString site)
 {
     this.m_unrestricted = false;
     this.m_urls = new URLString[] { site };
 }
        private static void DemandPermission(string codeBase, bool havePath, int demandFlag)
        {
            FileIOPermissionAccess pathDiscovery = FileIOPermissionAccess.PathDiscovery;
            switch (demandFlag)
            {
                case 1:
                    pathDiscovery = FileIOPermissionAccess.Read;
                    break;

                case 2:
                    pathDiscovery = FileIOPermissionAccess.PathDiscovery | FileIOPermissionAccess.Read;
                    break;

                case 3:
                    CreateWebPermission(AssemblyName.EscapeCodeBase(codeBase)).Demand();
                    return;
            }
            if (!havePath)
            {
                codeBase = new URLString(codeBase, true).GetFileName();
            }
            codeBase = Path.GetFullPathInternal(codeBase);
            new FileIOPermission(pathDiscovery, codeBase).Demand();
        }
        private void ParseURL()
        {
            lock (this)
            {
                if (m_element == null)
                    return;

                String elurl = m_element.Attribute( "Url" );
                if (elurl == null)
                {
                    throw new ArgumentException(Environment.GetResourceString("Argument_UrlCannotBeNull"));
                }
                else
                {
                    URLString url = new URLString(elurl);
                    if (url.IsRelativeFileUrl)
                        throw new ArgumentException(Environment.GetResourceString("Argument_RelativeUrlMembershipCondition"));

                    m_url = url;
                }

                m_element = null;
            }
        }
 internal UrlIdentityPermission( URLString site )
 {
     m_unrestricted = false;
     m_urls = new URLString[1];
     m_urls[0] = site;
 }
 // Token: 0x06002B61 RID: 11105 RVA: 0x000A1B58 File Offset: 0x0009FD58
 internal static string PreProcessForExtendedPathRemoval(string url, bool isFileUrl)
 {
     return(URLString.PreProcessForExtendedPathRemoval(true, url, isFileUrl));
 }
        public void FromXml( SecurityElement e, PolicyLevel level )
        {
            if (e == null)
                throw new ArgumentNullException("e");

            if (!e.Tag.Equals( "IMembershipCondition" ))
            {
                throw new ArgumentException( Environment.GetResourceString( "Argument_MembershipConditionElement" ) );
            }
            Contract.EndContractBlock();

            lock (this)
            {
                m_element = e;
                m_url = null;
            }
        }
Exemplo n.º 38
0
 private Url(Url url) 
 {
     Contract.Assert(url != null);
     m_url = url.m_url;
 } 
 internal static RuntimeAssembly InternalLoadAssemblyName(AssemblyName assemblyRef, System.Security.Policy.Evidence assemblySecurity, ref StackCrawlMark stackMark, bool forIntrospection, bool suppressSecurityChecks)
 {
     if (assemblyRef == null)
     {
         throw new ArgumentNullException("assemblyRef");
     }
     assemblyRef = (AssemblyName) assemblyRef.Clone();
     if (assemblySecurity != null)
     {
         if (!AppDomain.CurrentDomain.IsLegacyCasPolicyEnabled)
         {
             throw new NotSupportedException(Environment.GetResourceString("NotSupported_RequiresCasPolicyImplicit"));
         }
         if (!suppressSecurityChecks)
         {
             new SecurityPermission(SecurityPermissionFlag.ControlEvidence).Demand();
         }
     }
     string strA = VerifyCodeBase(assemblyRef.CodeBase);
     if ((strA != null) && !suppressSecurityChecks)
     {
         if (string.Compare(strA, 0, "file:", 0, 5, StringComparison.OrdinalIgnoreCase) != 0)
         {
             CreateWebPermission(assemblyRef.EscapedCodeBase).Demand();
         }
         else
         {
             URLString str2 = new URLString(strA, true);
             new FileIOPermission(FileIOPermissionAccess.PathDiscovery | FileIOPermissionAccess.Read, str2.GetFileName()).Demand();
         }
     }
     return nLoad(assemblyRef, strA, assemblySecurity, null, ref stackMark, true, forIntrospection, suppressSecurityChecks);
 }
 private ApplicationDirectory(URLString appDirectory)
 {
     Contract.Assert(appDirectory != null);
     m_appDirectory = appDirectory;
 }
Exemplo n.º 41
0
 public bool Equals(URLString url)
 {
     return(CompareUrls(this, url));
 }
        //------------------------------------------------------
        //
        // PUBLIC CONSTRUCTORS
        //
        //------------------------------------------------------

        internal UrlMembershipCondition()
        {
            m_url = null;
        }
Exemplo n.º 43
0
        public static bool CompareUrls(URLString url1, URLString url2)
        {
            if (url1 == null && url2 == null)
            {
                return(true);
            }

            if (url1 == null || url2 == null)
            {
                return(false);
            }

            url1.DoDeferredParse();
            url2.DoDeferredParse();

            URLString normalUrl1 = url1.SpecialNormalizeUrl();
            URLString normalUrl2 = url2.SpecialNormalizeUrl();

            // Compare protocol (case insensitive)

            if (String.Compare(normalUrl1.m_protocol, normalUrl2.m_protocol, StringComparison.OrdinalIgnoreCase) != 0)
            {
                return(false);
            }

            // Do special processing for file urls

            if (String.Compare(normalUrl1.m_protocol, "file", StringComparison.OrdinalIgnoreCase) == 0)
            {
                if (!normalUrl1.m_localSite.IsSubsetOf(normalUrl2.m_localSite) ||
                    !normalUrl2.m_localSite.IsSubsetOf(normalUrl1.m_localSite))
                {
                    return(false);
                }
            }
            else
            {
                if (String.Compare(normalUrl1.m_userpass, normalUrl2.m_userpass, StringComparison.Ordinal) != 0)
                {
                    return(false);
                }

                if (!normalUrl1.m_siteString.IsSubsetOf(normalUrl2.m_siteString) ||
                    !normalUrl2.m_siteString.IsSubsetOf(normalUrl1.m_siteString))
                {
                    return(false);
                }

                if (url1.m_port != url2.m_port)
                {
                    return(false);
                }
            }

            if (!normalUrl1.m_directory.IsSubsetOf(normalUrl2.m_directory) ||
                !normalUrl2.m_directory.IsSubsetOf(normalUrl1.m_directory))
            {
                return(false);
            }

            return(true);
        }
        // Token: 0x06002B62 RID: 11106 RVA: 0x000A1B64 File Offset: 0x0009FD64
        internal static string PreProcessForExtendedPathRemoval(bool checkPathLength, string url, bool isFileUrl)
        {
            bool flag = false;

            return(URLString.PreProcessForExtendedPathRemoval(checkPathLength, url, isFileUrl, ref flag));
        }
 private ApplicationDirectory(URLString appDirectory)
 {
     this.m_appDirectory = appDirectory;
 }
Exemplo n.º 46
0
 public bool Equals( URLString url ) 
 {
     return CompareUrls( this, url ); 
 }
        private void ParseURL()
        {
            lock (this)
            {
                if (m_element == null)
                    return;

                String elurl = m_element.Attribute( "Url" );
                if (elurl == null)
                    throw new ArgumentException( Environment.GetResourceString( "Argument_UrlCannotBeNull" ) );
                else
                    m_url = new URLString( elurl );

                m_element = null;
            }
        }
 private void VerifyCodeBaseDiscovery(string codeBase)
 {
     if ((codeBase != null) && (string.Compare(codeBase, 0, "file:", 0, 5, StringComparison.OrdinalIgnoreCase) == 0))
     {
         URLString str = new URLString(codeBase, true);
         new FileIOPermission(FileIOPermissionAccess.PathDiscovery, str.GetFileName()).Demand();
     }
 }