Class AbstractCookieStore

java.lang.Object
org.archive.modules.fetcher.AbstractCookieStore
All Implemented Interfaces:
org.apache.http.client.CookieStore, org.archive.checkpointing.Checkpointable, FetchHTTPCookieStore, org.springframework.context.Lifecycle
Direct Known Subclasses:
BdbCookieStore, SimpleCookieStore

public abstract class AbstractCookieStore
extends Object
implements org.springframework.context.Lifecycle, org.archive.checkpointing.Checkpointable, org.apache.http.client.CookieStore, FetchHTTPCookieStore
  • Field Details

    • MAX_COOKIES_FOR_DOMAIN

      public static final int MAX_COOKIES_FOR_DOMAIN
      See Also:
      Constant Field Values
    • logger

      protected final Logger logger
    • cookieComparator

      protected static final Comparator<org.apache.http.cookie.Cookie> cookieComparator
    • cookiesLoadFile

      protected org.archive.spring.ConfigFile cookiesLoadFile
    • cookiesSaveFile

      protected org.archive.spring.ConfigPath cookiesSaveFile
    • isRunning

      protected boolean isRunning
  • Constructor Details

    • AbstractCookieStore

      public AbstractCookieStore()
  • Method Details

    • getCookiesLoadFile

      public org.archive.spring.ConfigFile getCookiesLoadFile()
    • setCookiesLoadFile

      public void setCookiesLoadFile​(org.archive.spring.ConfigFile cookiesLoadFile)
    • getCookiesSaveFile

      public org.archive.spring.ConfigPath getCookiesSaveFile()
    • setCookiesSaveFile

      public void setCookiesSaveFile​(org.archive.spring.ConfigPath cookiesSaveFile)
    • start

      public void start()
      Specified by:
      start in interface org.springframework.context.Lifecycle
    • stop

      public void stop()
      Specified by:
      stop in interface org.springframework.context.Lifecycle
    • isRunning

      public boolean isRunning()
      Specified by:
      isRunning in interface org.springframework.context.Lifecycle
    • saveCookies

      public void saveCookies()
    • loadCookies

      protected void loadCookies​(org.archive.spring.ConfigFile file)
    • loadCookies

      protected void loadCookies​(Reader reader)
    • saveCookies

      public void saveCookies​(String saveCookiesFile)
    • readCookies

      protected Collection<org.apache.http.cookie.Cookie> readCookies​(Reader reader)
      Load cookies. The input is text in the Netscape's 'cookies.txt' file format. Example entry of cookies.txt file:

      www.archive.org FALSE / FALSE 1311699995 details-visit texts-cralond

      Each line has 7 tab-separated fields:

      1. DOMAIN: The domain that created and have access to the cookie value.
      2. FLAG: A TRUE or FALSE value indicating if hosts within the given domain can access the cookie value.
      3. PATH: The path within the domain that the cookie value is valid for.
      4. SECURE: A TRUE or FALSE value indicating if to use a secure connection to access the cookie value.
      5. EXPIRATION: The expiration time of the cookie value, or -1 for no expiration
      6. NAME: The name of the cookie value
      7. VALUE: The cookie value
      Parameters:
      reader - input in the Netscape's 'cookies.txt' format.
    • sortableKey

      protected String sortableKey​(org.apache.http.cookie.Cookie cookie)
      Returns a string that uniquely identifies the cookie, The format The format of the key is "normalizedDomain;name;path". Adapted from CookieIdentityComparator.compare(Cookie, Cookie).
    • normalizeHost

      protected String normalizeHost​(String host)
    • cookieStoreFor

      public org.apache.http.client.CookieStore cookieStoreFor​(CrawlURI curi) throws org.apache.commons.httpclient.URIException
      Description copied from interface: FetchHTTPCookieStore
      Returns a CookieStore whose CookieStore.getCookies() returns all the cookies that could possibly apply curi.
      Specified by:
      cookieStoreFor in interface FetchHTTPCookieStore
      Throws:
      org.apache.commons.httpclient.URIException
    • isCookieCountMaxedForDomain

      public boolean isCookieCountMaxedForDomain​(String domain)
    • addCookie

      public void addCookie​(org.apache.http.cookie.Cookie cookie)
      Specified by:
      addCookie in interface org.apache.http.client.CookieStore
    • expireCookie

      public abstract boolean expireCookie​(org.apache.http.cookie.Cookie cookie, Date date)
    • addCookieImpl

      protected abstract void addCookieImpl​(org.apache.http.cookie.Cookie cookie)
    • clear

      public abstract void clear()
      Specified by:
      clear in interface org.apache.http.client.CookieStore
    • prepare

      protected abstract void prepare()