当前位置: 首页>>代码示例>>Java>>正文


Java CookieStore.get方法代码示例

本文整理汇总了Java中java.net.CookieStore.get方法的典型用法代码示例。如果您正苦于以下问题:Java CookieStore.get方法的具体用法?Java CookieStore.get怎么用?Java CookieStore.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.net.CookieStore的用法示例。


在下文中一共展示了CookieStore.get方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: syncWebViewCookies

import java.net.CookieStore; //导入方法依赖的package包/类
public static void syncWebViewCookies(@NonNull Context context, @NonNull CookieStore cookieStore) {
    CookieSyncManager.createInstance(context);
    CookieManager cookieManager = CookieManager.getInstance();
    cookieManager.setAcceptCookie(true);
    cookieManager.removeSessionCookie();
    cookieManager.removeAllCookie();

    List<URI> urls = cookieStore.getURIs();
    for (URI url : urls) {
        List<HttpCookie> cookies = cookieStore.get(url);
        for (HttpCookie cookie : cookies) {
            cookieManager.setCookie(url.toString(), cookie.toString());
        }

        L.w("Cookies", cookieManager.getCookie(url.toString()));
    }

    CookieSyncManager.getInstance().sync();
}
 
开发者ID:ykrank,项目名称:S1-Next,代码行数:20,代码来源:WebViewUtils.java

示例2: clearAuthorizationData

import java.net.CookieStore; //导入方法依赖的package包/类
/**
 * Clear the local stored authorization data
 */
public void clearAuthorizationData() {
    preferences.accessToken.clear();
    preferences.idToken.clear();
    preferences.userIdentity.clear();
    if (BMSClient.getInstance() != null && BMSClient.getInstance().getCookieManager() != null) {
        CookieStore cookieStore = BMSClient.getInstance().getCookieManager().getCookieStore();
        if(cookieStore != null) {
            for (URI uri : cookieStore.getURIs()) {
                for (HttpCookie cookie : cookieStore.get(uri)) {
                    if (cookie.getName().equals(TAI_COOKIE_NAME)) {
                        cookieStore.remove(uri, cookie);
                    }
                }
            }
        }
    }
}
 
开发者ID:ibm-bluemix-mobile-services,项目名称:bms-clientsdk-android-core,代码行数:21,代码来源:MCAAuthorizationManager.java

示例3: resetCookie

import java.net.CookieStore; //导入方法依赖的package包/类
private void resetCookie() {
    settings.edit().remove(prefKey).apply();
    authCookie = "";
    try {
        /*
        This step is *required* for PNA, and nicety for other services. PNA won't let you
        log in if you're still holding on to a valid authcookie, so we clear them out.
         */
        URI loginURI = URI.create(url.getHost());
        CookieStore cookies = ((CookieManager) CookieHandler.getDefault()).getCookieStore();
        for (HttpCookie cookie : cookies.get(loginURI)) {
            cookies.remove(loginURI, cookie);
        }
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    }
    cookieHasBeenSet = false;
}
 
开发者ID:NasaGeek,项目名称:utexas-utilities,代码行数:19,代码来源:AuthCookie.java

示例4: writeTo

import java.net.CookieStore; //导入方法依赖的package包/类
public static void writeTo(
        @NotNull CookieStore store,
        @NotNull OutputStream stream
) throws IOException {
    HashMap<URI, List<SerializableHttpCookie>> cookieMap =
            new HashMap<URI, List<SerializableHttpCookie>>();

    List<URI> uris = store.getURIs();
    for (URI uri : uris) {
        List<HttpCookie> cookies = store.get(uri);
        List<SerializableHttpCookie> serializableHttpCookies =
                new ArrayList<SerializableHttpCookie>(cookies.size());
        for (HttpCookie cookie : cookies) {
            serializableHttpCookies.add(SerializableHttpCookie.of(cookie));
        }
        cookieMap.put(uri, serializableHttpCookies);
    }

    ByteArrayOutputStream os = new ByteArrayOutputStream();
    ObjectOutputStream oos = null;
    try {
        oos = new ObjectOutputStream(os);
        oos.writeObject(cookieMap);
        oos.flush();
        stream.write(os.toByteArray());
    } finally {
        IOUtils.closeQuietly(os);
        IOUtils.closeQuietly(oos);
    }
}
 
开发者ID:emoji-gen,项目名称:bottler,代码行数:31,代码来源:CookieStoreUtils.java

示例5: checkCookieNullUri

import java.net.CookieStore; //导入方法依赖的package包/类
static void checkCookieNullUri() throws Exception {
    //get a cookie store implementation and add a cookie to the store with null URI
    CookieStore cookieStore = (new CookieManager()).getCookieStore();
    //Check if removeAll() retrurns false on an empty CookieStore
    if (cookieStore.removeAll()) {
        fail = true;
    }
    checkFail("removeAll on empty store should return false");
    HttpCookie cookie = new HttpCookie("MY_COOKIE", "MY_COOKIE_VALUE");
    cookie.setDomain("foo.com");
    cookieStore.add(null, cookie);

    //Retrieve added cookie
    URI uri = new URI("http://foo.com");
    List<HttpCookie> addedCookieList = cookieStore.get(uri);

    //Verify CookieStore behaves well
    if (addedCookieList.size() != 1) {
       fail = true;
    }
    checkFail("Abnormal size of cookie jar");

    for (HttpCookie chip : addedCookieList) {
        if (!chip.equals(cookie)) {
             fail = true;
        }
    }
    checkFail("Cookie not retrieved from Cookie Jar");
    boolean ret = cookieStore.remove(null,cookie);
    if (!ret) {
        fail = true;
    }
    checkFail("Abnormal removal behaviour from Cookie Jar");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:35,代码来源:NullUriCookieTest.java

示例6: initUserIdFromCookies

import java.net.CookieStore; //导入方法依赖的package包/类
/**
 * Sets logged in user id from COOKIE_USER_ID if cookieStore has it
 */
private void initUserIdFromCookies() {
    CookieStore cookieStore = cookieManager.getCookieStore();
    try {
        List<HttpCookie> cookies = cookieStore.get(new URI(EcoMapAPIContract.ECOMAP_SERVER_URL));
        for (HttpCookie cookie : cookies) {
            if (cookie.getName().equals(EcoMapAPIContract.COOKIE_USER_ID)) {
                setUserId(cookie.getValue());
            }
        }
    } catch (URISyntaxException e) {
        Log.e(LOG_TAG, e.getMessage(), e);
    }
}
 
开发者ID:ITsvetkoFF,项目名称:Kv-009,代码行数:17,代码来源:MainActivity.java

示例7: checkCookieNullUri

import java.net.CookieStore; //导入方法依赖的package包/类
static void checkCookieNullUri() throws Exception {
    //get a cookie store implementation and add a cookie to the store with null URI
    CookieStore cookieStore = (new CookieManager()).getCookieStore();
    HttpCookie cookie = new HttpCookie("MY_COOKIE", "MY_COOKIE_VALUE");
    cookie.setDomain("foo.com");
    cookieStore.add(null, cookie);

    //Retrieve added cookie
    URI uri = new URI("http://foo.com");
    List<HttpCookie> addedCookieList = cookieStore.get(uri);

    //Verify CookieStore behaves well
    if (addedCookieList.size() != 1) {
       fail = true;
    }
    checkFail("Abnormal size of cookie jar");

    for (HttpCookie chip : addedCookieList) {
        if (!chip.equals(cookie)) {
             fail = true;
        }
    }
    checkFail("Cookie not retrieved from Cookie Jar");
    boolean ret = cookieStore.remove(null,cookie);
    if (!ret) {
        fail = true;
    }
    checkFail("Abnormal removal behaviour from Cookie Jar");
}
 
开发者ID:greghaskins,项目名称:openjdk-jdk7u-jdk,代码行数:30,代码来源:NullUriCookieTest.java


注:本文中的java.net.CookieStore.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。