/** * Removes all of {@link Cookie cookies} in this HTTP state * that have expired by the specified {@link java.util.Date date}. * * @return true if any cookies were purged. * * @see Cookie#isExpired(Date) */ public synchronized boolean clearExpired(final Date date) { if (date == null) { return false; } boolean removed = false; for (Iterator<Cookie> it = cookies.iterator(); it.hasNext();) { if (it.next().isExpired(date)) { it.remove(); removed = true; } } return removed; }
/** * Adds an {@link Cookie HTTP cookie}, replacing any existing equivalent cookies. * If the given cookie has already expired it will not be added, but existing * values will still be removed. * * @param cookie the {@link Cookie cookie} to be added * * @see #addCookies(Cookie[]) * */ public synchronized void addCookie(Cookie cookie) { if (cookie != null) { // first remove any old cookie that is equivalent for (Iterator<Cookie> it = cookies.iterator(); it.hasNext();) { if (cookieComparator.compare(cookie, it.next()) == 0) { it.remove(); break; } } if (!cookie.isExpired(new Date())) { cookies.add(cookie); } } }
public void addCookieImpl(Cookie cookie) { byte[] key; try { key = sortableKey(cookie).getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); // impossible } if (!cookie.isExpired(new Date())) { cookies.put(key, cookie); } else { cookies.remove(key); } }
@Override public boolean isExpired( Date date ) { return delegate.isExpired( date ); }
@Override public boolean isExpired( Date date ) { return delegate.isExpired( date ); }
public boolean isExpired(final Date date) { return cookie.isExpired(date); }
public synchronized void addCookie(Cookie cookie) { if (cookie != null) { // first remove any old cookie that is equivalent for (Iterator<Cookie> it = cookies.iterator(); it.hasNext();) { if (cookieComparator.compare(cookie, it.next()) == 0) { it.remove(); break; } } if (!cookie.isExpired(new Date())) { cookies.add(cookie); } } }
public synchronized boolean clearExpired(final Date date) { if (date == null) { return false; } boolean removed = false; for (final Iterator<org.apache.http.cookie.Cookie> it = cookies.iterator(); it.hasNext();) { if (it.next().isExpired(date)) { it.remove(); removed = true; } } return removed; }
/** * Adds an {@link Cookie HTTP cookie}, replacing any existing equivalent cookies. * If the given cookie has already expired it will not be added, but existing * values will still be removed. * * @param cookie the {@link Cookie cookie} to be added * * @see #addCookies(Cookie[]) * */ @Override public synchronized void addCookie(final Cookie cookie) { if (cookie != null) { // first remove any old cookie that is equivalent cookies.remove(cookie); if (!cookie.isExpired(new Date())) { cookies.add(cookie); } } }
/** * Adds an {@link Cookie HTTP cookie}, replacing any existing equivalent cookies. * If the given cookie has already expired it will not be added, but existing * values will still be removed. * * @param cookie the {@link Cookie cookie} to be added * * @see #addCookies(Cookie[]) * */ public synchronized void addCookie(final Cookie cookie) { if (cookie != null) { // first remove any old cookie that is equivalent cookies.remove(cookie); if (!cookie.isExpired(new Date())) { cookies.add(cookie); } } }
/** * Removes all of {@link Cookie cookies} in this HTTP state * that have expired by the specified {@link java.util.Date date}. * * @return true if any cookies were purged. * * @see Cookie#isExpired(Date) */ @Override public synchronized boolean clearExpired(final Date date) { if (date == null) { return false; } boolean removed = false; for (final Iterator<Cookie> it = cookies.iterator(); it.hasNext();) { if (it.next().isExpired(date)) { it.remove(); removed = true; } } return removed; }
/** * Removes all of {@link Cookie cookies} in this HTTP state that have expired by the specified * {@link java.util.Date date}. * * @return true if any cookies were purged. * * @see Cookie#isExpired(Date) */ public boolean clearExpired(final Date date) { if (date == null) { return false; } boolean removed = false; for (Iterator<Cookie> it = cookies.iterator(); it.hasNext();) { if (it.next().isExpired(date)) { it.remove(); removed = true; } } return removed; }
/** * Removes all of {@link Cookie cookies} in this HTTP state * that have expired by the specified {@link java.util.Date date}. * * @return true if any cookies were purged. * * @see Cookie#isExpired(Date) */ public synchronized boolean clearExpired(final Date date) { if (date == null) { return false; } boolean removed = false; for (final Iterator<Cookie> it = cookies.iterator(); it.hasNext();) { if (it.next().isExpired(date)) { it.remove(); removed = true; } } return removed; }
@Override public void addCookie(Cookie cookie) { String name = cookie.getName(); // Save cookie into local store, or remove if expired if(!cookie.isExpired(new Date())) { cookies.put(name, cookie); } else { cookies.remove(name); } // Save cookie into persistent store SharedPreferences.Editor prefsWriter = cookiePrefs.edit(); prefsWriter.putString(COOKIE_NAME_STORE, TextUtils.join(",", cookies.keySet())); prefsWriter.putString(COOKIE_NAME_PREFIX + name, encodeCookie(new SerializableCookie(cookie))); prefsWriter.commit(); }
public void addCookieImpl(Cookie cookie) { byte[] key; try { key = sortableKey(cookie).getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); // impossible } if (!cookie.isExpired(new Date())) { cookies.put(key, cookie); } else { cookies.remove(key); } }
@Override public void addCookie(Cookie cookie) { String name = cookie.getName() + cookie.getDomain(); // Save cookie into local store, or remove if expired if (!cookie.isExpired(new Date())) { cookies.put(name, cookie); } else { cookies.remove(name); } // Save cookie into persistent store SharedPreferences.Editor prefsWriter = cookiePrefs.edit(); prefsWriter.putString(COOKIE_NAME_STORE, TextUtils.join(",", cookies.keySet())); prefsWriter.putString(COOKIE_NAME_PREFIX + name, encodeCookie(new SerializableCookie(cookie))); prefsWriter.commit(); }
public synchronized void addCookie(final org.apache.http.cookie.Cookie cookie) { if (cookie != null) { log.debug("Add cookie : name={}, path={}, value={},", cookie.getName(), cookie.getPath(), cookie.getValue()); // first remove any old cookie that is equivalent cookies.remove(cookie); if (!cookie.isExpired(new Date())) { cookies.add(cookie); } } }
@Override public void addCookie(Cookie cookie) { if (omitNonPersistentCookies && !cookie.isPersistent()) return; String name = cookie.getName() + cookie.getDomain(); // Save cookie into local store, or remove if expired if (!cookie.isExpired(new Date())) { cookies.put(name, cookie); } else { cookies.remove(name); } // Save cookie into persistent store SharedPreferences.Editor prefsWriter = cookiePrefs.edit(); prefsWriter.putString(COOKIE_NAME_STORE, TextUtils.join(",", cookies.keySet())); prefsWriter.putString(COOKIE_NAME_PREFIX + name, encodeCookie(new SerializableCookie(cookie))); prefsWriter.commit(); }
private boolean hasValidatAuthenticationState() { List<Cookie> cookies = new ArrayList<Cookie>(getClient().getHttpClient().getCookieStore().getCookies()); if (cookies != null) { for (Cookie cookie : cookies) { if ("JSESSIONID".equals(cookie.getName())) { return !cookie.isExpired(new Date()); } } } return false; }
/** * Adds an {@link Cookie HTTP cookie}, replacing any existing equivalent cookies. If the given * cookie has already expired it will not be added, but existing values will still be removed. * * @param cookie the {@link Cookie cookie} to be added * * @see #addCookies(HashMap) * */ @Override public void addCookie(final Cookie cookie) { if (cookie != null) { // first remove any old cookie that is equivalent cookies.remove(cookie.getDomain() + cookie.getName() + cookie.getPath()); if (!cookie.isExpired(new Date())) { cookies.put(cookie.getDomain() + cookie.getName() + cookie.getPath(), cookie); } } }