예제 #1
0
		public List< KnetikCookie > GetCookies( KnetikCookieAccessInfo accessInfo )
		{
			List< KnetikCookie > result = new List< KnetikCookie >();
			foreach ( string cookieName in cookies.Keys )
			{
				KnetikCookie cookie = this.GetCookie( cookieName, accessInfo );
				if ( cookie != null )
				{
                    result.Add( cookie );
				}
			}
			
			return result;
		}
예제 #2
0
		public bool CollidesWith( KnetikCookieAccessInfo 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;
		}
예제 #3
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 KnetikCookie GetCookie( string name, KnetikCookieAccessInfo accessInfo )
		{
			if ( !cookies.ContainsKey( name ) )
			{
                return null;
			}
			
			for ( int index = 0; index < cookies[ name ].Count; ++index )
			{
				KnetikCookie cookie = cookies[ name ][ index ];
				if ( cookie.expirationDate > DateTime.Now && cookie.Matches( accessInfo ) )
				{
                    return cookie;
				}
			}
			
            return null;
		}
예제 #4
0
		// Ensure that Cookie matches existing access information
		public bool Matches( KnetikCookieAccessInfo accessInfo )
		{
			if (    this.secure != accessInfo.secure
			     || !this.CollidesWith( accessInfo ) )
			{
				return false;
			}
			
			return true;
		}