Ejemplo n.º 1
0
        public bool CollidesWith(CookieAccessInfo accessInfo)
        {
            if ((this.path != null && accessInfo.path == null) || (this.domain != null && accessInfo.domain == null))
            {
                return(false);
            }

            if (this.path != null && accessInfo.path != null && accessInfo.path.IndexOf(this.path) != 0)
            {
                return(false);
            }

            if (this.domain == accessInfo.domain)
            {
                return(true);
            }
            else if (this.domain != null && this.domain.Length >= 1 && this.domain[0] == '.')
            {
                int wildcard = accessInfo.domain.IndexOf(this.domain.Substring(1));
                if (wildcard == -1 || wildcard != accessInfo.domain.Length - this.domain.Length + 1)
                {
                    return(false);
                }
            }
            else if (this.domain != null)
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 2
0
 public bool CollidesWith(CookieAccessInfo accessInfo)
 {
     if ((path != null && accessInfo.path == null) || (domain != null && accessInfo.domain == null))
     {
         return(false);
     }
     if (path != null && accessInfo.path != null && accessInfo.path.IndexOf(path) != 0)
     {
         return(false);
     }
     if (domain == accessInfo.domain)
     {
         return(true);
     }
     if (domain != null && domain.Length >= 1 && domain[0] == '.')
     {
         int num = accessInfo.domain.IndexOf(domain.Substring(1));
         if (num == -1 || num != accessInfo.domain.Length - domain.Length + 1)
         {
             return(false);
         }
     }
     else if (domain != null)
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 3
0
 public bool Matches(CookieAccessInfo accessInfo)
 {
     if (secure != accessInfo.secure || !CollidesWith(accessInfo))
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 4
0
        public List <Cookie> GetCookies(CookieAccessInfo accessInfo)
        {
            List <Cookie> list = new List <Cookie>();

            foreach (string key in cookies.Keys)
            {
                Cookie cookie = GetCookie(key, accessInfo);
                if (cookie != null)
                {
                    list.Add(cookie);
                }
            }
            return(list);
        }
Ejemplo n.º 5
0
        public List <Cookie> GetCookies(CookieAccessInfo accessInfo)
        {
            List <Cookie> result = new List <Cookie>();

            foreach (string cookieName in cookies.Keys)
            {
                Cookie cookie = this.GetCookie(cookieName, accessInfo);
                if (cookie != null)
                {
                    result.Add(cookie);
                }
            }

            return(result);
        }
Ejemplo n.º 6
0
 public Cookie GetCookie(string name, CookieAccessInfo accessInfo)
 {
     if (!cookies.ContainsKey(name))
     {
         return(null);
     }
     for (int i = 0; i < cookies[name].Count; i++)
     {
         Cookie cookie = cookies[name][i];
         if (cookie.expirationDate > DateTime.Now && cookie.Matches(accessInfo))
         {
             return(cookie);
         }
     }
     return(null);
 }
Ejemplo n.º 7
0
		public List< Cookie > GetCookies( CookieAccessInfo accessInfo )
		{
			List< Cookie > result = new List< Cookie >();
			foreach ( string cookieName in cookies.Keys )
			{
                Cookie cookie = this.GetCookie( cookieName, accessInfo );
				if ( cookie != null )
				{
                    result.Add( cookie );
				}
			}
			
			return result;
		}
Ejemplo n.º 8
0
        // TODO: figure out a way to respect the scriptAccessible flag and supress cookies being
        //       returned that should not be.  The issue is that at some point, within this
        //       library, we need to send all the correct cookies back in the request.  Right now
        //       there's no way to add all cookies (regardless of script accessibility) to the
        //       request without exposing cookies that should not be script accessible.
        
		public Cookie GetCookie( string name, CookieAccessInfo accessInfo )
		{
			if ( !cookies.ContainsKey( name ) )
			{
                return null;
			}
			
			for ( int index = 0; index < cookies[ name ].Count; ++index )
			{
				Cookie cookie = cookies[ name ][ index ];
				if ( cookie.expirationDate > DateTime.Now && cookie.Matches( accessInfo ) )
				{
                    return cookie;
				}
			}
			
            return null;
		}
Ejemplo n.º 9
0
		public bool CollidesWith( CookieAccessInfo accessInfo )
		{
			if ( ( this.path != null && accessInfo.path == null ) || ( this.domain != null && accessInfo.domain == null ) )
			{
				return false;
			}
			
			if ( this.path != null && accessInfo.path != null && accessInfo.path.IndexOf( this.path ) != 0 )
			{
                return false;
			}
			
			if ( this.domain == accessInfo.domain )
			{
                return true;
			}
			else if ( this.domain != null && this.domain.Length >= 1 && this.domain[ 0 ] == '.' )
			{
                int wildcard = accessInfo.domain.IndexOf( this.domain.Substring( 1 ) );
				if( wildcard == -1 || wildcard != accessInfo.domain.Length - this.domain.Length + 1 )
				{
                    return false;
				}
			}
			else if ( this.domain != null )
			{
                return false;
			}

            return true;
		}
Ejemplo n.º 10
0
		public bool Matches( CookieAccessInfo accessInfo )
		{
			if (    this.secure != accessInfo.secure
			     || !this.CollidesWith( accessInfo ) )
			{
				return false;
			}
			
			return true;
		}