Package rife.engine

Class SiteCookieFileStore

java.lang.Object
rife.engine.SiteCookieFileStore
All Implemented Interfaces:
SiteCookieStore

public class SiteCookieFileStore extends Object implements SiteCookieStore
Stores the cookies of a SiteCookieJar in a file.

The file is replaced as a whole each time the cookies change, so that it's never left half written when your application is stopped. Only java.io is used for this, since on iOS parts of java.nio.file bring along a disk space call that Apple wants a reason for in the privacy manifest of your app.

The cookies can be credentials, so the file should be in a location that your application protects, its own application support directory for instance.

Since:
1.11.0
  • Constructor Details

    • SiteCookieFileStore

      public SiteCookieFileStore(File file)
      Creates a store that keeps the cookies in a file.
      Parameters:
      file - the file of the cookies, which doesn't have to exist yet
      Since:
      1.11.0
  • Method Details

    • getFile

      public File getFile()
      Retrieves the file of the cookies.
      Returns:
      the file of this store
      Since:
      1.11.0
    • load

      public Collection<SiteCookie> load()
      Description copied from interface: SiteCookieStore
      Provides the cookies that were stored before. The jar will drop the ones that have expired.
      Specified by:
      load in interface SiteCookieStore
      Returns:
      the stored cookies; or

      null if there are none

    • save

      public void save(Collection<SiteCookie> cookies)
      Description copied from interface: SiteCookieStore
      Stores all the cookies that should last. This method will be called each time they change.
      Specified by:
      save in interface SiteCookieStore
      Parameters:
      cookies - the cookies to store, which replace what was stored before