当前位置: 首页>>代码示例>>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;未经允许,请勿转载。