Java Code Examples for org.apache.http.cookie.Cookie#isPersistent()

The following examples show how to use org.apache.http.cookie.Cookie#isPersistent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PersistentCookieStore.java    From Mobike with Apache License 2.0 6 votes vote down vote up
@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();
}
 
Example 2
Source File: PersistentCookieStore.java    From AndroidWear-OpenWear with MIT License 6 votes vote down vote up
@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();
}
 
Example 3
Source File: PersistentCookieStore.java    From BigApp_Discuz_Android with Apache License 2.0 6 votes vote down vote up
@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();
}
 
Example 4
Source File: PersistentCookieStore.java    From android-project-wo2b with Apache License 2.0 6 votes vote down vote up
@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();
}
 
Example 5
Source File: PersistentCookieStore.java    From Android-Basics-Codes with Artistic License 2.0 6 votes vote down vote up
@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();
}
 
Example 6
Source File: PersistentCookieStore.java    From Android-Basics-Codes with Artistic License 2.0 6 votes vote down vote up
@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();
}
 
Example 7
Source File: PersistentCookieStore.java    From Android-Basics-Codes with Artistic License 2.0 6 votes vote down vote up
@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();
}
 
Example 8
Source File: PersistentCookieStore.java    From MiBandDecompiled with Apache License 2.0 6 votes vote down vote up
public void addCookie(Cookie cookie)
{
    if (e && !cookie.isPersistent())
    {
        return;
    }
    String s = (new StringBuilder()).append(cookie.getName()).append(cookie.getDomain()).toString();
    android.content.SharedPreferences.Editor editor;
    if (!cookie.isExpired(new Date()))
    {
        f.put(s, cookie);
    } else
    {
        f.remove(s);
    }
    editor = g.edit();
    editor.putString("names", TextUtils.join(",", f.keySet()));
    editor.putString((new StringBuilder()).append("cookie_").append(s).toString(), encodeCookie(new SerializableCookie(cookie)));
    editor.commit();
}
 
Example 9
Source File: HttpTest.java    From hsac-fitnesse-fixtures with Apache License 2.0 5 votes vote down vote up
/**
 * @param cookieName name of cookie.
 * @return whether cookie in the cookie store is persistent.
 */
public Boolean cookieIsPersistent(String cookieName) {
    Boolean result = null;
    Cookie cookie = getCookie(cookieName);
    if (cookie != null) {
        result = cookie.isPersistent();
    }
    return result;
}