當前位置: 首頁>>代碼示例>>Java>>正文


Java CookieStore.clear方法代碼示例

本文整理匯總了Java中org.apache.http.client.CookieStore.clear方法的典型用法代碼示例。如果您正苦於以下問題:Java CookieStore.clear方法的具體用法?Java CookieStore.clear怎麽用?Java CookieStore.clear使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.http.client.CookieStore的用法示例。


在下文中一共展示了CookieStore.clear方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: fillSession

import org.apache.http.client.CookieStore; //導入方法依賴的package包/類
/**
 * 將登錄結果保存到給定會話對象中,並激活給定會話對象。
 * @param session 會話對象
 * @throws IllegalStateException 登錄未成功時拋出
 * @throws NetworkException 在發生網絡問題時拋出
 */
public void fillSession(Session session) throws BiliLiveException {
    try {
        if (status != SUCCESS) throw new IllegalStateException("Bad status: " + status);

        Set<Cookie> cookies = webClient.getCookieManager().getCookies();

        CookieStore store = session.getCookieStore();
        store.clear();
        for (Cookie cookie : cookies) {
            store.addCookie(cookie.toHttpClient()); // HtmlUnit Cookie to HttpClient Cookie
        }

        if (getStatus() == SUCCESS) session.activate();
    } catch (IOException ex) {
        throw new NetworkException("IO Exception", ex);
    }
}
 
開發者ID:cqjjjzr,項目名稱:BiliLiveLib,代碼行數:24,代碼來源:SessionLoginHelper.java

示例2: fromBase64

import org.apache.http.client.CookieStore; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public static void fromBase64(@NotNull Session session, @NonNls @NotNull String base64) {
    try {
        ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64.getDecoder().decode(base64.getBytes()));
        ObjectInputStream objectInputStream = new ObjectInputStream(inputStream);
        List<Cookie> cookies = (List<Cookie>) objectInputStream.readObject();

        CookieStore store = session.getCookieStore();
        store.clear();
        for (Cookie cookie : cookies) {
            store.addCookie(cookie);
        }
    } catch (IOException | ClassNotFoundException e) {
        throw new AssertionError();
    }
}
 
開發者ID:cqjjjzr,項目名稱:BiliLiveLib,代碼行數:17,代碼來源:SessionPersistenceHelper.java

示例3: testSuccessfulAuthAfterResettingCookieStore

import org.apache.http.client.CookieStore; //導入方法依賴的package包/類
@Test
public void testSuccessfulAuthAfterResettingCookieStore() {
    ResponseEntity<String> result = authenticatedRestTemplate.getForEntity("", String.class);
    Assert.assertEquals(HttpStatus.SC_OK, result.getStatusCode().value());

    logger.debug("Muck with cookie store (ie. maybe a session got changed on a prevous random request");
    CookieStore cookieStore = authenticatedRestTemplate.getRestTemplate().getCookieStore();
    cookieStore.clear();

    logger.debug("The subsequent request is still fine");
    result = authenticatedRestTemplate.getForEntity("", String.class);
    Assert.assertEquals(HttpStatus.SC_OK, result.getStatusCode().value());
}
 
開發者ID:box,項目名稱:mojito,代碼行數:14,代碼來源:AuthenticationTest.java

示例4: cleanCookie

import org.apache.http.client.CookieStore; //導入方法依賴的package包/類
public static void cleanCookie(Context context){
    CookieStore cookieStore = com.youzu.clan.base.net.CookieManager.getInstance().getCookieStore(context);
    cookieStore.clear();

    removeWebViewCookie(context);
}
 
開發者ID:BigAppOS,項目名稱:BigApp_Discuz_Android,代碼行數:7,代碼來源:CookieUtils.java


注:本文中的org.apache.http.client.CookieStore.clear方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。