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


Java BasicClientCookie.setExpiryDate方法代碼示例

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


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

示例1: batchCookie

import org.apache.http.impl.cookie.BasicClientCookie; //導入方法依賴的package包/類
/**
 * batchCookies
 * 
 * @param cookiestring
 *            the cookie string, eg.:"a=b;c=a"
 * @param domain
 *            the domain
 * @param path
 *            the path
 * @param expired
 *            the expired date
 */
public synchronized void batchCookie(String cookiestring, String domain, String path, Date expired) {
	String[] ss = X.split(cookiestring, ";");
	for (String s : ss) {
		StringFinder sf = StringFinder.create(s);
		String name = sf.nextTo("=");
		String value = sf.remain();
		if (!X.isEmpty(name)) {
			removeCookie(name, domain, path);

			BasicClientCookie c = new BasicClientCookie(name, value);
			c.setDomain(domain);
			c.setPath(X.isEmpty(path) ? "/" : path);
			c.setExpiryDate(expired);
			cookies.addCookie(c);
		}
	}
}
 
開發者ID:giiwa,項目名稱:giiwa,代碼行數:30,代碼來源:Http.java

示例2: makeCookie

import org.apache.http.impl.cookie.BasicClientCookie; //導入方法依賴的package包/類
/**
 * Create an HttpClient cookie from a JMeter cookie
 */
private org.apache.http.cookie.Cookie makeCookie(Cookie jmc) {
    long exp = jmc.getExpiresMillis();
    BasicClientCookie ret = new BasicClientCookie(jmc.getName(),
            jmc.getValue());
    ret.setDomain(jmc.getDomain());
    ret.setPath(jmc.getPath());
    ret.setExpiryDate(exp > 0 ? new Date(exp) : null); // use null for no expiry
    ret.setSecure(jmc.getSecure());
    ret.setVersion(jmc.getVersion());
    if(jmc.isDomainSpecified()) {
        ret.setAttribute(ClientCookie.DOMAIN_ATTR, jmc.getDomain());
    }
    if(jmc.isPathSpecified()) {
        ret.setAttribute(ClientCookie.PATH_ATTR, jmc.getPath());
    }
    return ret;
}
 
開發者ID:johrstrom,項目名稱:cloud-meter,代碼行數:21,代碼來源:HC4CookieHandler.java

示例3: seleniumCookiesToCookieStore

import org.apache.http.impl.cookie.BasicClientCookie; //導入方法依賴的package包/類
/**
 * Get Cookie from WebDriver browser session.
 *
 * @return cookieStore from WebDriver browser session.
 */
private static CookieStore seleniumCookiesToCookieStore() {

    Set<Cookie> seleniumCookies = WebDriverWrapper.getDriver().manage().getCookies();
    CookieStore cookieStore = new BasicCookieStore();

    for (Cookie seleniumCookie : seleniumCookies) {
        BasicClientCookie basicClientCookie =
                new BasicClientCookie(seleniumCookie.getName(), seleniumCookie.getValue());
        basicClientCookie.setDomain(seleniumCookie.getDomain());
        basicClientCookie.setExpiryDate(seleniumCookie.getExpiry());
        basicClientCookie.setPath(seleniumCookie.getPath());
        cookieStore.addCookie(basicClientCookie);
    }

    return cookieStore;
}
 
開發者ID:ggasoftware,項目名稱:gga-selenium-framework,代碼行數:22,代碼來源:FileUtil.java

示例4: shareCookies

import org.apache.http.impl.cookie.BasicClientCookie; //導入方法依賴的package包/類
/**
 * Share the cookies with HttpClientTask
 */
public void shareCookies(){
  Object store = getCookieStore();
  if (store == null){
    store = new BasicCookieStore();
    this.getParametersInner().put(HttpClientTask.PARAM_HTTP_COOKIES, store);
  }
  
  CookieStore cookieStore = (CookieStore)store; 
  for (Cookie cookie : this.getDriver().manage().getCookies()){
    BasicClientCookie newCookie = new BasicClientCookie(cookie.getName(), cookie.getValue());
    newCookie.setDomain(cookie.getDomain());
    newCookie.setPath(cookie.getPath());
    newCookie.setExpiryDate(cookie.getExpiry());
    newCookie.setSecure(cookie.isSecure());
    cookieStore.addCookie(newCookie);
  }
}
 
開發者ID:detectiveframework,項目名稱:detective,代碼行數:21,代碼來源:GebDetectivePage.java

示例5: clearCookieForHost

import org.apache.http.impl.cookie.BasicClientCookie; //導入方法依賴的package包/類
protected synchronized void clearCookieForHost(String sessionHost) throws Exception {
  Cookie sessionCookie = null;
  for (Cookie cookie : cookieStore.getCookies()) {
    String cookieDomain = cookie.getDomain();
    if (cookieDomain != null) {
      if (sessionHost.equals(cookieDomain) ||
              sessionHost.indexOf(cookieDomain) != -1 ||
              cookieDomain.indexOf(sessionHost) != -1) {
        sessionCookie = cookie;
        break;
      }
    }
  }

  if (sessionCookie != null) {
    BasicClientCookie httpCookie = new BasicClientCookie(sessionCookie.getName(), sessionCookie.getValue());
    httpCookie.setExpiryDate(new Date(0));
    httpCookie.setVersion(1);
    httpCookie.setPath(sessionCookie.getPath());
    httpCookie.setDomain(sessionCookie.getDomain());
    cookieStore.addCookie(httpCookie);
  }

  cookieStore.clearExpired(new Date()); // this should clear the cookie
}
 
開發者ID:lucidworks,項目名稱:solr-scale-tk,代碼行數:26,代碼來源:FusionPipelineClient.java

示例6: importCookies

import org.apache.http.impl.cookie.BasicClientCookie; //導入方法依賴的package包/類
public static void importCookies(CookieStore cookieStore, JSONArray cookies) {
	cookieStore.clear();
	
	for (int i = 0; i < cookies.length(); i++) {
		try {
			JSONObject json = cookies.getJSONObject(i);
			if (json.has("domain") && json.has("expiryDate")
				&& json.has("name") && json.has("value")) {
				BasicClientCookie cookie = new BasicClientCookie(json.getString("name"), json.getString("value"));
				cookie.setDomain(json.getString("domain"));
				cookie.setPath(json.getString("path"));
				long expiryTs = json.getLong("expiryDate");
				cookie.setExpiryDate(new Date(expiryTs));
				cookieStore.addCookie(cookie);
			}
		} catch (JSONException e) {
			logger.error(e.getMessage(), e);
		}
	}
}
 
開發者ID:askeing,項目名稱:jplurk,代碼行數:21,代碼來源:ISettings.java

示例7: getAllCookies

import org.apache.http.impl.cookie.BasicClientCookie; //導入方法依賴的package包/類
public List<Cookie> getAllCookies() {
	List<Cookie> cookies = new ArrayList<Cookie>();

	Cursor cursor = db
			.query(TABLE_NAME, null, null, null, null, null, null);

	for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
		String name = cursor.getString(cursor.getColumnIndex(Column.NAME));
		String value = cursor
				.getString(cursor.getColumnIndex(Column.VALUE));

		BasicClientCookie cookie = new BasicClientCookie(name, value);

		cookie.setComment(cursor.getString(cursor
				.getColumnIndex(Column.COMMENT)));
		cookie.setDomain(cursor.getString(cursor
				.getColumnIndex(Column.DOMAIN)));
		long expireTime = cursor.getLong(cursor
				.getColumnIndex(Column.EXPIRY_DATE));
		if (expireTime != 0) {
			cookie.setExpiryDate(new Date(expireTime));
		}
		cookie.setPath(cursor.getString(cursor.getColumnIndex(Column.PATH)));
		cookie.setSecure(cursor.getInt(cursor.getColumnIndex(Column.SECURE)) == 1);
		cookie.setVersion(cursor.getInt(cursor
				.getColumnIndex(Column.VERSION)));

		cookies.add(cookie);
	}

	cursor.close();

	return cookies;
}
 
開發者ID:SShineTeam,項目名稱:Huochexing12306,代碼行數:35,代碼來源:MyCookieDBManager.java

示例8: readObject

import org.apache.http.impl.cookie.BasicClientCookie; //導入方法依賴的package包/類
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    String name = (String) in.readObject();
    String value = (String) in.readObject();
    clientCookie = new BasicClientCookie(name, value);
    clientCookie.setComment((String) in.readObject());
    clientCookie.setDomain((String) in.readObject());
    clientCookie.setExpiryDate((Date) in.readObject());
    clientCookie.setPath((String) in.readObject());
    clientCookie.setVersion(in.readInt());
    clientCookie.setSecure(in.readBoolean());
}
 
開發者ID:LanguidSheep,項目名稱:sealtalk-android-master,代碼行數:12,代碼來源:SerializableCookie.java

示例9: mimicCookieState

import org.apache.http.impl.cookie.BasicClientCookie; //導入方法依賴的package包/類
/**
 * Load in all the cookies WebDriver currently knows about so that we can mimic the browser cookie state
 *
 * @param seleniumCookieSet
 * @return
 */
private BasicCookieStore mimicCookieState(Set<Cookie> seleniumCookieSet) {
    BasicCookieStore mimicWebDriverCookieStore = new BasicCookieStore();
    for (Cookie seleniumCookie : seleniumCookieSet) {
        BasicClientCookie duplicateCookie = new BasicClientCookie(seleniumCookie.getName(), seleniumCookie.getValue());
        duplicateCookie.setDomain(seleniumCookie.getDomain());
        duplicateCookie.setSecure(seleniumCookie.isSecure());
        duplicateCookie.setExpiryDate(seleniumCookie.getExpiry());
        duplicateCookie.setPath(seleniumCookie.getPath());
        mimicWebDriverCookieStore.addCookie(duplicateCookie);
    }
 
    return mimicWebDriverCookieStore;
}
 
開發者ID:GovernIB,項目名稱:helium,代碼行數:20,代碼來源:FileDownloader.java

示例10: addCookie

import org.apache.http.impl.cookie.BasicClientCookie; //導入方法依賴的package包/類
public Builder addCookie(String name, String value, Instant expires, String path, String domain) {
    BasicClientCookie clientCookie = new BasicClientCookie(name, value);
    clientCookie.setExpiryDate(Date.from(expires));
    clientCookie.setPath(path);
    clientCookie.setDomain(domain);
    cookies.add(clientCookie);
    return this;
}
 
開發者ID:tempofeng,項目名稱:lambda-local,代碼行數:9,代碼來源:RestResponseEntity.java

示例11: readObject

import org.apache.http.impl.cookie.BasicClientCookie; //導入方法依賴的package包/類
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    String key = (String) in.readObject();
    String value = (String) in.readObject();
    clientCookie = new BasicClientCookie(key, value);
    clientCookie.setComment((String) in.readObject());
    clientCookie.setDomain((String) in.readObject());
    clientCookie.setExpiryDate((Date) in.readObject());
    clientCookie.setPath((String) in.readObject());
    clientCookie.setVersion(in.readInt());
    clientCookie.setSecure(in.readBoolean());
}
 
開發者ID:hcq0618,項目名稱:AndroidWear-OpenWear,代碼行數:12,代碼來源:SerializableCookie.java

示例12: testServerReceivesCookiesSentFromClient

import org.apache.http.impl.cookie.BasicClientCookie; //導入方法依賴的package包/類
@Test
public void testServerReceivesCookiesSentFromClient() throws Exception {
    BasicClientCookie clientCookie = new BasicClientCookie("name", "value");
    Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.DAY_OF_YEAR, 100);
    clientCookie.setExpiryDate(calendar.getTime());
    clientCookie.setDomain("localhost");
    this.httpclient.getCookieStore().addCookie(clientCookie);
    HttpGet httpget = new HttpGet("http://localhost:8192/");
    ResponseHandler<String> responseHandler = new BasicResponseHandler();
    this.httpclient.execute(httpget, responseHandler);

    assertEquals(1, this.testServer.cookiesReceived.size());
    assertTrue(this.testServer.cookiesReceived.get(0).getHTTPHeader().contains("name=value"));
}
 
開發者ID:panda73111,項目名稱:FakeLocation,代碼行數:16,代碼來源:CookieIntegrationTest.java

示例13: testExpiredCookie

import org.apache.http.impl.cookie.BasicClientCookie; //導入方法依賴的package包/類
@Test
public void testExpiredCookie() throws Exception {
    final BasicCookieStore store = new BasicCookieStore();
    final BasicClientCookie cookie = new BasicClientCookie("name1", "value1");

    final Calendar c = Calendar.getInstance();
    c.add(Calendar.DAY_OF_YEAR, -10);
    cookie.setExpiryDate(c.getTime());
    store.addCookie(cookie);
    final List<Cookie> l = store.getCookies();
    Assert.assertNotNull(l);
    Assert.assertEquals(0, l.size());
}
 
開發者ID:MyPureCloud,項目名稱:purecloud-iot,代碼行數:14,代碼來源:TestBasicCookieStore.java

示例14: mimicCookieState

import org.apache.http.impl.cookie.BasicClientCookie; //導入方法依賴的package包/類
/**
 * Load in all the cookies WebDriver currently knows about so that we can mimic the browser
 * cookie state
 *
 * @param seleniumCookieSet
 *            Set&lt;Cookie&gt;
 */
private BasicCookieStore mimicCookieState(Set<Cookie> seleniumCookieSet) {
	BasicCookieStore copyOfWebDriverCookieStore = new BasicCookieStore();
	for (Cookie seleniumCookie : seleniumCookieSet) {
		BasicClientCookie duplicateCookie = new BasicClientCookie(seleniumCookie.getName(),
				seleniumCookie.getValue());
		duplicateCookie.setDomain(seleniumCookie.getDomain());
		duplicateCookie.setSecure(seleniumCookie.isSecure());
		duplicateCookie.setExpiryDate(seleniumCookie.getExpiry());
		duplicateCookie.setPath(seleniumCookie.getPath());
		copyOfWebDriverCookieStore.addCookie(duplicateCookie);
	}

	return copyOfWebDriverCookieStore;
}
 
開發者ID:gautamsabba,項目名稱:UIFramework,代碼行數:22,代碼來源:FileDownloader.java

示例15: clearCookieForHost

import org.apache.http.impl.cookie.BasicClientCookie; //導入方法依賴的package包/類
protected synchronized void clearCookieForHost(String sessionHost) throws Exception {
  Cookie sessionCookie = null;
  for (Cookie cookie : cookieStore.getCookies()) {
    String cookieDomain = cookie.getDomain();
    if (cookieDomain != null) {
      if (sessionHost.equals(cookieDomain) ||
        sessionHost.indexOf(cookieDomain) != -1 ||
        cookieDomain.indexOf(sessionHost) != -1)
      {
        sessionCookie = cookie;
        break;
      }
    }
  }

  if (sessionCookie != null) {
    BasicClientCookie httpCookie =
      new BasicClientCookie(sessionCookie.getName(),sessionCookie.getValue());
    httpCookie.setExpiryDate(new Date(0));
    httpCookie.setVersion(1);
    httpCookie.setPath(sessionCookie.getPath());
    httpCookie.setDomain(sessionCookie.getDomain());
    cookieStore.addCookie(httpCookie);
  }

  cookieStore.clearExpired(new Date()); // this should clear the cookie
}
 
開發者ID:lucidworks,項目名稱:storm-solr,代碼行數:28,代碼來源:FusionPipelineClient.java


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