java.lang.Object
org.eclipse.jgit.internal.transport.http.NetscapeCookieFile
Wraps all cookies persisted in a Netscape Cookie File Format
being referenced via the git config http.cookieFile.
It will only load the cookies lazily, i.e. before calling
getCookies(boolean)
the file is not evaluated. This class also
allows persisting cookies in that file format.
In general this class is not thread-safe. So any consumer needs to take care of synchronization!
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetCookies
(boolean refresh) Return all cookies from the underlying cookie file.getPath()
Path to the underlying cookie file.void
Writes all the cookies being maintained in the set being returned bygetCookies(boolean)
to the underlying file.
-
Constructor Details
-
NetscapeCookieFile
- Parameters:
path
- where to find the cookie file
-
-
Method Details
-
getPath
Path to the underlying cookie file.- Returns:
- the path
-
getCookies
Return all cookies from the underlying cookie file.- Parameters:
refresh
- iftrue
updates the list from the underlying cookie file if it has been modified since the last read otherwise returns the current transient state. In case the cookie file has never been read before will always read from the underlying file disregarding the value of this parameter.- Returns:
- all cookies (may contain session cookies as well). This does not
return a copy of the list but rather the original one. Every
addition to the returned list can afterwards be persisted via
write(URL)
. Errors in the underlying file will not lead to exceptions but rather to an empty set being returned and the underlying error being logged.
-
write
Writes all the cookies being maintained in the set being returned bygetCookies(boolean)
to the underlying file.Session-cookies will not be persisted.
- Parameters:
url
- url for which to write the cookies (important to derive default values for non-explicitly set attributes)- Throws:
IOException
- if the underlying cookie file could not be read or written or a problem with the lock fileInterruptedException
- if the thread is interrupted while waiting for the lock
-