コード例 #1
0
ファイル: Cookie.cs プロジェクト: r8zbeh/cscore
 public bool CollidesWith(CookieAccessInfo accessInfo)
 {
     if (this.domain != null && accessInfo.domain == null)
     {
         return(false);
     }
     if (this.path != null && accessInfo.path == 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);
 }
コード例 #2
0
ファイル: Cookie.cs プロジェクト: r8zbeh/cscore
 public bool Matches(CookieAccessInfo accessInfo)
 {
     if (this.secure != accessInfo.secure)
     {
         return(false);
     }
     return(CollidesWith(accessInfo));
 }
コード例 #3
0
ファイル: CookieJar.cs プロジェクト: r8zbeh/cscore
        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);
        }
コード例 #4
0
ファイル: CookieJar.cs プロジェクト: r8zbeh/cscore
        // 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.Matches(accessInfo))
                {
                    AssertV2.IsTrue(cookie.expirationDate.ToUnixTimestampUtc() > 0, "cookie.expirationDate.toUnixTimestamp()=" + cookie.expirationDate.ToUnixTimestampUtc());
                    if (cookie.expirationDate.IsAfter(DateTimeV2.UtcNow))
                    {
                        return(cookie);
                    }
                    else
                    {
                        Log.w("Matching but expired cookie found, expirationDate=" + cookie.expirationDate.ToReadableString() + "; cookie=" + cookie);
                    }
                }
            }
            return(null);
        }