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 Matches(CookieAccessInfo accessInfo)
        {
            if (this.secure != accessInfo.secure ||
                !this.CollidesWith(accessInfo))
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 3
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.º 4
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.º 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
        // 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.º 7
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.º 8
0
		public bool Matches( CookieAccessInfo accessInfo )
		{
			if (    this.secure != accessInfo.secure
			     || !this.CollidesWith( accessInfo ) )
			{
				return false;
			}
			
			return true;
		}